1. No module named _caffe

import caffe
Traceback (most recent call last):
File "", line 1, in
File "caffe/init.py", line 1, in
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "caffe/pycaffe.py", line 13, in
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver,
ImportError: No module named _caffe

解决方法:

  • 为caffe添加环境变量,并重新编译pycaffe
sudo gedit ~/.bashrc 
export PYTHONPATH=~/caffe/python:$PYTHONPATH
source ~/.bashrc
sudo make pycaffe

这个问题的原因是设置的训练GPU数量和真实物理机上的显卡数量不相等,回到solover文件下,或者caffe的python执行文件,设置运行的GPU数量和指定GPU即可。

  • 将solver.prototxt文件中的device_id项改为自己的GPU块数,0/1/2/3
device_id=0
  • 将ssd_pascal.py文件中第332行gpus = "0,1,2,3"的GPU选择改为gpus = "0";两张显卡时,则保留0/1,删除2/3
gpus = "0"
  • 由于博主只有一块GPU且电脑运行内存有限,为了避免出现“Check failed: error == cudaSuccess (2 vs. 0) invalid ...”的错误。还需要将ssd_pascal.py文件中的337行batch_size = 32和338行accum_batch_size = 32都改小一倍,即更改批量大小,
batch_size = 16
accum_batch_size = 16

参考链接

【1】 https://blog.csdn.net/jiyangsb/article/details/77724876
【2】https://blog.csdn.net/touch_dream/article/details/80520024