caffe和caffe2编译无法加载protobuf相关问题解决办法

今天在家编译处理caffe时,发现存在以下问题:

File "/home/zhangwei/caffe/python/caffe/pycaffe.py", line 13, in

    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: libprotobuf.so.15: cannot open shared object file: No such file or directory

主要是重新安装protobuf-3.5.1新版本(protobuf-3.5.1是下载的源码解压后编译的,版本3.5.1,系统默认安装的2.6.1的,才caffe模型转caffe2时会出现问题)所导致的,通过执行一下命令:

 sudo find / -name libprotobuf.so.15
/home/zhangwei/protobuf-3.5.1/src/.libs/libprotobuf.so.15

发现确实存在libprotobuf.so.15(备注libprotobuf.so.15时一个软链接文件)

ls -l /home/zhangwei/protobuf-3.5.1/src/.libs/libprotobuf.so.15

lrwxrwxrwx 1 zhangwei zhangwei 21 3月  17 09:57 /home/zhangwei/protobuf-3.5.1/src/.libs/libprotobuf.so.15 -> libprotobuf.so.15.0.1

解决办法:

zhangwei@ubuntu:~/protobuf-3.5.1/src/.libs$        sudo cp libprotobuf.so.15.0.1 /usr/local/lib/
zhangwei@ubuntu:~/protobuf-3.5.1/src/.libs$ sudo ln -s /usr/local/lib/libprotobuf.so.15.0.1 /usr/local/lib/libprotobuf.so.15


在处理caffe2时发现

/usr/local/bin/protoc: error while loading shared libraries: libprotoc.so.15: cannot open shared object file: No such file or directory

third_party/onnx/CMakeFiles/onnx_proto.dir/build.make:61: recipe for target 'third_party/onnx/onnx/onnx_onnx_c2.pb.cc' failed
make[2]: *** [third_party/onnx/onnx/onnx_onnx_c2.pb.cc] Error 127
通过以下命令:
zhangwei@ubuntu:/usr/local/bin$ sudo find / -name protoc
                /home/zhangwei/protobuf-3.5.1/src/.libs/protoc
                /home/zhangwei/protobuf-3.5.1/src/protoc
                /usr/local/bin/protoc
                /usr/share/bash-completion/completions/protoc
                /usr/bin/protoc

发现protoc确实存在,可能是版本偏低问题,于是执行:

sudo cp /home/zhangwei/protobuf-3.5.1/src/protoc /usr/local/bin/

sudo cp /home/zhangwei/protobuf-3.5.1/src/protoc /usr/local/

 sudo cp /home/zhangwei/protobuf-3.5.1/src/protoc /usr/share/bash-completion/completions






你可能感兴趣的:(caffe和caffe2编译无法加载protobuf相关问题解决办法)