(写在前面的废话) 由于调试代码需要,需要安装caffe环境,网上教程很多,主要步骤是github下载,修改makeflie的两个文件,然后make。于是我这个新手小白就开始安装了。各种报错和调试,终究没能编译通过。而且报的错误网上也查不到,可把我头疼坏了。 错误主要和***cudnn***有关!!!
发现是cudnn版本问题,于是我又从giyhub上下载了cudnn8的caffe框架,依旧以失败告终。 最后的最后,降低了cuda和cudnn版本,编译通过!!! **`
》》》》》》》》结论:caffe不支持cuDNN8!!!!《《《《《《《《
`** 原来的
cuda11.2+cuDNN8.2.0
降低后
cuda10.2+cuDNN7.6.5
最后caffe安装过程参考 ubuntu16.04+anaconda3+python2.7虚拟环境+caffe配置过程及踩坑经历 多版本cuda安装过程和一般的一样,就是涉及到版本切换的软连接问题。可以参考 linux下安装多版本cuda和cudnn
**
我的配置是 ubuntu18.04+anaconda3+py27虚拟环境+cuda10.2+cuDNN7.6.5
》》》》》》》》》》》》》》》》 最后《《《《《《《《《《《《
** make test ,make runtest make pycaffe都没有问题
import caffe报错,继续填坑
问题1:
>>>import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bjl/env/caffe/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "/home/bjl/env/caffe/python/caffe/pycaffe.py", line 13, in <module>
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: /home/bjl/env/caffe/python/caffe/_caffe.so: undefined symbol: _ZN5caffe3NetIfE21CopyTrainedLayersFromERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
解决1: 删除/usr/lib/x86_64-linux-gnu/下的libcaffe.so.1.0.0文件
sudo rm -f /usr/lib/x86_64-linux-gnu/libcaffe.so.1.0.0
问题2
>>> import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bjl/env/caffe/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "/home/bjl/env/caffe/python/caffe/pycaffe.py", line 13, in <module>
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: /home/bjl/anaconda3/envs/py27/bin/../lib/libgio-2.0.so.0: undefined symbol: g_unix_get_passwd_entry
解决2:
conda install -c anaconda glib==2.56.1
问题3
>>> import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bjl/env/caffe/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "/home/bjl/env/caffe/python/caffe/pycaffe.py", line 15, in <module>
import caffe.io
File "/home/bjl/env/caffe/python/caffe/io.py", line 2, in <module>
import skimage.io
解决3
conda install scikit-image
问题4
>>> import caffe
/home/bjl/anaconda3/envs/py27/lib/python2.7/site-packages/matplotlib/font_manager.py:278: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
'Matplotlib is building the font cache using fc-list. '
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bjl/env/caffe/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "/home/bjl/env/caffe/python/caffe/pycaffe.py", line 15, in <module>
import caffe.io
File "/home/bjl/env/caffe/python/caffe/io.py", line 8, in <module>
from caffe.proto import caffe_pb2
File "/home/bjl/env/caffe/python/caffe/proto/caffe_pb2.py", line 6, in <module>
from google.protobuf.internal import enum_type_wrapper
ImportError: No module named google.protobuf.internal
解决4
pip2 install protobuf
终于!
>>> import caffe
>>>
新的服务器,新的白给小码农,还有数不尽的坑。。。
|