zoukankan      html  css  js  c++  java
  • windows编译caffe2遇到的问题

    首先介绍下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. 运行找到下载好的caffe2scriptsuild_host_protoc.sh

    4.运行caffe2scriptsuild_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:caffe2uildALL_BUILD.vcxproj”(默认目标) (1) ->
    “X:caffe2uildcaffe2caffe2_pybind11_state.vcxproj”(默认目标) (8) ->
    (Link 目标) ->
      LINK : fatal error LNK1104: cannot open “python27.lib” [X:caffe2uildcaffe2caffe2_pybind11_state.vcxproj]
    解决方法:打开Caffe2.sln,然后安装图中操作:


    然后就可以通过VS编译一下Caffe2,至此Caffe2编译完成。

    编译完后将caffe2_pybind11_state.pyd拷贝都python的DLLs目录例如:XXXAnaconda2DLLs

    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。

     
     
  • 相关阅读:
    libmv
    visualSFM
    opencv学习笔记——时间计算函数getTickCount()和getTickFrequency()
    opencv学习笔记——cv::mean()函数详解
    linux使用ip能ping通,但使用域名却不能访问的解决方法
    yum 安装出错--"Couldn't resolve host 'mirrors.aliyun.com'"
    vmware复制虚拟机出现Error:No suitable device found:no device found for connection 'System eth0'
    VMWare虚拟机 网络连接模式
    js监听input输入框值的实时变化实例
    本地连接linux虚拟机的方法
  • 原文地址:https://www.cnblogs.com/ydxt/p/9114696.html
Copyright © 2011-2022 走看看