编译caffe2遇到的坑

编译caffe2源码遇到的坑


最新的caffe2 已经移到pytorch中去了,直接下载其中的代码然后按照官方教程就可以了。

编译遇到的问题:

make[3]: Entering directory '/home/ubuntu/caffe2-master/build'
make[3]: Leaving directory '/home/ubuntu/caffe2-master/build'
make[3]: Entering directory '/home/ubuntu/caffe2-master/build'
[ 92%] Linking CXX executable ../bin/mpi_test
/usr/bin/ld: CMakeFiles/mpi_test.dir/mpi/mpi_test.cc.o: undefined reference to symbol '_ZN3MPI8Datatype4FreeEv'
//usr/lib/libmpi_cxx.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
caffe2/CMakeFiles/mpi_test.dir/build.make? recipe for target 'bin/mpi_test' failed
make[3]: *** [bin/mpi_test] Error 1
make[3]: Leaving directory '/home/ubuntu/caffe2-master/build'
CMakeFiles/Makefile2:2654: recipe for target 'caffe2/CMakeFiles/mpi_test.dir/all' failed
make[2]: *** [caffe2/CMakeFiles/mpi_test.dir/all] Error 2
make[2]: Leaving directory '/home/ubuntu/caffe2-master/build'
Makefile:140: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/ubuntu/caffe2-master/build'
Makefile:4: recipe for target 'all' failed
make: *** [all] Error 2

问题出在MPI的链接问题中。

因此你需要修改的文件如下:
pytorch->caffe2->CMakefiles.txt
添加如下到最后行就可以了:

SET(CMAKE_C_COMPILER mpicc)
SET(CMAKE_CXX_COMPILER mpicxx)
include_directories(MPI_INCLUDE_PATH)
target_link_libraries(mpi_test ${MPI_LIBRARIES})

测试遇到的问题

再输入测试时候会遇到问题:
python -c 'from caffe2.python import core'
发现不能import caffe2_pb,这一步其实是因为路径存在问题。
如果你位于PATH_TO/pytorch/build
你就会发现,可以解决了,因此你需要把这个目录加载到PYTHONPATH中去。
具体方法:
echo 'export PYTHONPATH=$PYTHONPATH:PATH_TO/pytorch/build' >> ~/.bashrc
中去。然后
source ~/.bashrc
就可以了。

其中PATH_TO需要根据你自己的电脑上的目录操作。

评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值