First, the following window compiles the CAFFE2 overall process:
Description: If you do not need Python support just 3, 4, and the compilation will not be the problem.
1. Install the python2.7.
I'm using the Anaconda python2.7 environment to add a Python path to the system path (Pyth).
2.python installation of some necessary libraries, such as NumPy, PYBIND11 (must not be verified?? )
Specific other dependent libraries see URLs:
Https://caffe2.ai/docs/getting-started.html?platform=windows&configuration=compile
I installed the library:
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. Run to find the downloaded caffe2\scripts\build_host_protoc.sh
4. Running Caffe2\scripts\build_windows.bat
Be aware of this:
If PYTHON support is required, set "-dbuild_python=off^" to "-dbuild_python=on^"
If off you can safely compile, set to on after you encounter the problem described below.
Problems encountered and solutions:
1. Problem cannot find NumPy, make sure Python is installed
Similar to: Could not find NumPy (Missing:numpy_include_dir numpy_version) error.
Workaround:
Remove the previous numpy and reinstall the NumPy to resolve the issue.
Delete: Pip uninstall NumPy
Installation: Pip Install Nump
2. Question:
CMake Summary Output
I am installing Caffe2 on win10 and it takes me almost a whole day. There is many missing Argvs and errors in build_windows.bat . I doubt that the script have 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: The system cannot find the file specified. (System can not find specified file)
CMake Error at cmake/utils.cmake:177 (message):
Python dedent failed with error code: The system cannot find the file specified. (System can not find specified file)
Call Stack (most recent call first):
cmake/utils.cmake:200 (dedent)
caffe2/cmakelists.txt:145 (Pycmd)
Workaround:
Modify the Cmake/utils.cmake file, the problem is estimated that the caffe2 will not be updated.
See URL: Https://github.com/pytorch/pytorch/pull/6296/commits/88ae3f4c4feb50532b64b2f5d1110a7c2e81ceb6
3. Problem cannot be connectedpython27.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. But will report no module's fault.
>>> Import Caffe2
Traceback (most recent):
File "<stdin>", line 1, in <module>
Importerror:no module named Caffe2
Solution (1):
>>> Import Sys
>>> sys.path.append ("X:/xxxx/caffe2/build")
>>> Import Caffe2
>>> Import Caffe2.python
Solution (2):
Reference URL: https://www.cnblogs.com/shanql/articles/5477483.html
Under Windows: Locate the Site-packages folder in the Python installation environment:
New Mypkpath.pth (Note: You must have a. pth suffix), and then save the X:/xxxx/caffe2/build write in the file.
The purpose of this approach should be similar to C, C + + to tell python the header file, run-time python to find the corresponding DLL.
Issues encountered by Windows compilation Caffe2