首先介绍下window编译caffe2整体流程:

说明:如果不需要python支持只需3、4即可,而且编译亦不会出现问题。

1. 安装python2.7,。

我使用的是anaconda python2.7环境,要将python路径添加到系统路径(PYTH)。

2.python一些必要库的安装,如numpy、pybind11(是否必须未验证??)

  具体其他依赖库参见网址:

  https://caffe2.ai/docs/getting-started.html?platform=windows&configuration=compile

  我安装的库:  

  pip install future hypothesis numpy protobuf six
  pip install flask glog graphviz jupyter matplotlib pydot python-nvd3 pyyaml requests scikit-image scipy setuptools tornado

  pip install pybind11

3. 运行找到下载好的caffe2\scripts\build_host_protoc.sh

4.运行caffe2\scripts\build_windows.bat

此时要注意:

如果需要python支持需要将“-DBUILD_PYTHON=OFF^”设置为“-DBUILD_PYTHON=ON^”

如果为OFF大家可以放心编译,设置为ON后会遇到下面描述的问题。

遇到问题及解决方法:

1. 问题找不到numpy,确定python中已经安装

类似:Could NOT find NumPy (missing: NUMPY_INCLUDE_DIR NUMPY_VERSION) 错误。

解决方法:

这时将以前的numpy删除,重新安装numpy即可解决问题。

删除: pip uninstall numpy

安装:pip install nump

2.问题:

CMake summary output

I am installing caffe2 on win10 and it takes me almost a whole day. There are many missing argvs and errors in build_windows.bat. I doubt that the script has not been tested before.
Now I have another problem afer executing build_windows.bat:
ERROR Failed to remove indentation from:
"""

  from distutils import sysconfig
print(sysconfig.get_python_lib(prefix=''))

"""
Python dedent failed with error code: 系统找不到指定的文件。(system can not find specified file)
CMake Error at cmake/Utils.cmake:177 (message):
Python dedent failed with error code: 系统找不到指定的文件。(system can not find specified file)
Call Stack (most recent call first):
cmake/Utils.cmake:200 (dedent)
caffe2/CMakeLists.txt:145 (pycmd)

解决方法:

修改cmake/Utils.cmake文件,这个问题估计再更新的caffe2就会没有了。

参见网址:https://github.com/pytorch/pytorch/pull/6296/commits/88ae3f4c4feb50532b64b2f5d1110a7c2e81ceb6

3. 问题无法连接python27.lib

“X:\caffe2\build\ALL_BUILD.vcxproj”(默认目标) (1) ->
“X:\caffe2\build\caffe2\caffe2_pybind11_state.vcxproj”(默认目标) (8) ->
(Link 目标) ->
LINK : fatal error LNK1104: cannot open “python27.lib” [X:\caffe2\build\caffe2\caffe2_pybind11_state.vcxproj]
解决方法:打开Caffe2.sln,然后安装图中操作:
然后就可以通过VS编译一下Caffe2,至此Caffe2编译完成。 编译完后将caffe2_pybind11_state.pyd拷贝都python的DLLs目录例如:XXX\Anaconda2\DLLs 4. python使用:
import caffe2。但是会报no module的错。

>>> import caffe2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named caffe2

解决方案(1):

>>> import sys
>>> sys.path.append("X:/XXXX/caffe2/build")
>>> import caffe2
>>> import caffe2.python

解决方案(2):

参考网址:https://www.cnblogs.com/shanql/articles/5477483.html

windows下:找到python安装环境中的site-packages文件夹:

新建mypkpath.pth(注:必须以.pth为后缀),然后在文件中将X:/XXXX/caffe2/build写入保存即可。

这样的做法目的应该是类似C、C++将头文件告诉python,运行时python再找对应的dll。

 
 

windows编译caffe2遇到的问题的更多相关文章

  1. OGRE 2.1 Windows 编译

    版权所有,转载请注明链接 OGRE 2.1 Windows 编译 环境: Windows 7 64Bit Visual Studio 2012 OGRE 2.1 CMake 2.8.12.1 OGRE ...

  2. Windows编译ejabberd

    Windows编译ejabberd(金庆的专栏)安装 erlang OTP. 添加路径到 PATH, 使 erl 可以运行.git clone ejabberd安装 rebar:git clone g ...

  3. 【转载】OGRE 2.1 Windows 编译

    OGRE 2.1 Windows 编译 环境: Windows 7 64Bit Visual Studio 2012 OGRE 2.1 CMake 2.8.12.1 OGRE: OGRE官方推出了最新 ...

  4. CEF3.2623使用记录:windows编译

    CEF3.2623使用记录:windows编译 1:cef3.2623下载地址 2623是cef3最后一个支持xp系统的版本,且可以支持html的audio标签,可以用作对html音频的处理下载地址为 ...

  5. Windows 编译安装 nginx 服务器 + rtmp 模块

    有关博客: <Windows 编译安装 nginx 服务器 + rtmp 模块>.<Ubuntu 编译安装 nginx>.<Arm-Linux 移植 Nginx> ...

  6. php beast windows编译教程

    git clone https://github.com/Microsoft/php-sdk-binary-tools.git c:\php-sdk cd c:\php-sdk git checkou ...

  7. Win10上使用VS2015编译Caffe2

    Caffe2的官网:https://caffe2.ai/ 1.下载.安装及相关准备 在Caffe2的官网点击"Get Started",即进入安装说明页面.官方还未提供编译好的bi ...

  8. Windows编译Nginx源码

    Windows下的Nginx战役,人不作就不会死!就像是拿着麦当劳的优惠券去买肯德基一样,别扭啊 Nginx是一款轻量级的Web 服务器.反向代理服务器.邮件服务器等等集一大串荣誉于一身的大牌人物!他 ...

  9. 在windows编译MariaDB

    OS: Windows XP sp3 IDE: VS2010 MariaDB: V5.5 (到目前为止2016.5,中文域(.cn)只有清华大学 TUNA 镜像源可用) (.tar.gz为源码:.zi ...

随机推荐

  1. 2018-9-2-WPF-开发自动开机启动程序

    title author date CreateTime categories WPF 开发自动开机启动程序 lindexi 2018-09-02 15:10:52 +0800 2018-9-2 14 ...

  2. 跟我一起认识axure(二)

    创建企业网站页面步骤 第一步修改这里 变成 第一部分就完成了 第二部分部件窗口 在Axure中设计页面像小时候玩的拼图游戏,那么部件窗口就是专门用来存放拼图块的容器 使用部件窗口中常用的部件设计欢迎页 ...

  3. 2018年DDoS攻击全态势:战胜第一波攻击成“抗D” 关键

    2018年,阿里云安全团队监测到云上DDoS攻击发生近百万次,日均攻击2000余次.目前阿里云承载着中国40%网站,为全球上百万客户提供基础安全防御.可以说,阿里云上的攻防态势是整个中国攻防态势的缩影 ...

  4. acm一路走来的体验和想法

    2017年参加天梯赛 作为大一萌新去参加人生第一场正规的比赛,学校拿钱砸的.我呢,是十分激动的,是时候检验下自己的编程水平了,也有一丝慌张,怕给团队抹黑. 然后呢,晒一下自己成绩. 我本来觉得我和他们 ...

  5. 快速启动Oracle服务

    快速启动Oracle服务的批处理命令步骤 新建记事本 粘贴如下内容: @echo off echo 确定要启动Oracle 11g服务吗? pause net start OracleOraDb11g ...

  6. Java练习 SDUT-1132_斐波那契数列

    C/C++经典程序训练2---斐波那契数列 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 编写计算斐波那契(Fibon ...

  7. @codeforces - 1205D@ Almost All

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个 n 个点的无向树. 请在每条边上写上权值,使得对于每一 ...

  8. 2、asp.net core 部署到服务器之后外网访问不了

    解决问题 把自定义端口的http://localhost:5001改成http://*:5001. 什么都没有改也不行的小伙伴试试在Program的Main方法中的.UseKestrel()后面添加. ...

  9. iptables 伪装(Masquerading)

    「偽装」是一种特殊的SNAT操作:将来自其它电脑的包的来源位址改成自己的位址:请注意,由於入替的来源位址是自动決定的(执行SNAT的主机的IP位址).所以,如果它改变了,仍在持续中的旧连線将会失效.「 ...

  10. 15个非常重要的Apache开源项目汇总

    15个非常重要的Apache开源项目汇总 自1999年创立以来,Apache软件基金会如今已成了众多重要的开源软件项目之家.本文列举了15个多年来非常重要的Apache项目,这些项目不仅对开源运动来说 ...