Caffe安装过程中遇到requirement.txt 的python包依赖等问题

版权声明:本文为博主原创文章,未经博主允许不得转载,转载请设置文章链接! https://blog.csdn.net/qq_30460905/article/details/86238506

之前在自己笔记本上配置过一次caffe,只用的cpu,啊,简直不能要。。。后来换了TX1试试,又得重新编译一边caffe,每次在编译python包时总是难以满足,尝试好久,有点心得,主要整理一下python依赖解决过程,免得遗忘。

1、开始步骤

下载caffe,参考教程一大堆,自己找~

Note:Makefile也要修改一下,不只是Makefile.config,不然会出现找不到lhdf5_hl 和 lhdf5

参考文章:https://blog.csdn.net/u012841667/article/details/53316948

#出现下面错误
/usr/bin/ld: 找不到 -lhdf5_hl
/usr/bin/ld: 找不到 -lhdf5
collect2: error: ld returned 1 exit status
Makefile:566: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1

#Makefile 181行,更改hdf5_hl 和 hdf5 
#LIBRARIES += glog gflags protobuf boost_system boost_filesystem boost_regex m hdf5_hl hdf5
LIBRARIES += glog gflags protobuf boost_system boost_filesystem boost_regex m hdf5_serial_hl hdf5_serial

然后你会来到下面这一步

cd ~/caffe
sudo apt-get install gfortran
cd ./python
su
for req in $(cat requirements.txt); do pip install $req; done

2、解决requirements依赖

执行完最后一句命令,会出现各种包不满足,这个时候直接打开requirements.txt,然后对照出错的包,一条一条的执行,这样错误比较清晰,方便解决。

pip install scipy #不满足的包

此时可能会出现一些简单的错误,解决后,如果还是不能安装,可以尝试

sudo apt-get install python-scipy #记得用Tab

我的scipy和leveldb就是用这种方法安装的,pip怎么都安不上,用apt-get很容易就安上了。

3、解决scikit-image包的安装问题

采用pip install scikit-image 每次都卡在Installing build dependencies ... |好久也没什么反应,然后我就取消了,发现它有好几个依赖包,每次取消后同样都需要重新下载,我就决定单个依赖安装。

nvidia@tegra-ubuntu:~$ sudo pip install dask

nvidia@tegra-ubuntu:~$ sudo pip install cloudpickle

nvidia@tegra-ubuntu:~$ sudo pip install PyWavelets
....
#安完各个依赖后,最后尝试
nvidia@tegra-ubuntu:~$ sudo pip install scikit-image
#终于出现了
Collecting scikit-image
  Downloading https://files.pythonhosted.org/packages/a4/5d/05d40ad281cb16bc9dbd91982a918162b374c43e84eb2c8f7070e4be6729/scikit-image-0.14.1.tar.gz (27.5MB)
    100% |████████████████████████████████| 27.5MB 688kB/s 
  Installing build dependencies ... done
Requirement already satisfied: networkx>=1.8 in /usr/local/lib/python2.7/dist-packages (from scikit-image) (2.2)
Requirement already satisfied: six>=1.10.0 in /usr/lib/python2.7/dist-packages (from scikit-image) (1.10.0)
Requirement already satisfied: pillow>=4.3.0 in ./.local/lib/python2.7/site-packages (from scikit-image) (5.1.0)
Requirement already satisfied: PyWavelets>=0.4.0 in /usr/local/lib/python2.7/dist-packages (from scikit-image) (1.0.1)
Requirement already satisfied: dask[array]>=0.9.0 in /usr/local/lib/python2.7/dist-packages (from scikit-image) (1.0.0)
Requirement already satisfied: cloudpickle>=0.2.1 in /usr/local/lib/python2.7/dist-packages (from scikit-image) (0.6.1)
Requirement already satisfied: decorator>=4.3.0 in /usr/local/lib/python2.7/dist-packages (from networkx>=1.8->scikit-image) (4.3.0)
Requirement already satisfied: numpy>=1.9.1 in ./.local/lib/python2.7/site-packages (from PyWavelets>=0.4.0->scikit-image) (1.14.5)
Requirement already satisfied: toolz>=0.7.3; extra == "array" in /usr/local/lib/python2.7/dist-packages (from dask[array]>=0.9.0->scikit-image) (0.9.0)
Installing collected packages: scikit-image
  Running setup.py install for scikit-image ... done
Successfully installed scikit-image-0.14.1

NOTE:

1、在Running setup.py 那里至少停了有十分钟,千万不要着急关闭窗口,可能机器正编译着呢,突然回想起之间我的多次中断。。。所以年轻还是要耐得住性子,哈哈

2、pip安装过程中可能会出现让你升级pip,升级pip后出现ImportError: cannot import name main

参考链接:https://blog.csdn.net/accumulate_zhang/article/details/80269313

cd /usr/bin

sudo gedit pip

#修改下面三行
from pip import main
if __name__ == '__main__':
    sys.exit(main())

#改为以下三行
from pip import __main__
if __name__ == '__main__':
    sys.exit(__main__._main())

3、安装过程中会出现有些包安装不上,干脆直接下载,相关软件包可以去python官网下:https://pypi.org/   然后执行

sudo pip install *.whl

4、安装python相关软件包时会有相关版本不满足,不知道为啥,然后发现命令行确实找的包不对,已经电脑满足了,就是pyyaml!!!参考:Ubuntu安装yaml
或者可以进入python环境查看一下你这个包的版本:

import pyyaml
pyyaml.__version__
或者help,翻到最后就是软件包版本信息
help(pyyaml)

5、python程序运行时检查空格 python -tt file_name.py
在终端窗口执行某个脚本时,脚本中的当前目录" ./ "或 “ os.getpwd() ”为终端的路径,而非脚本路径,这时如果脚本中有读取脚本所在目录文件操作时就会找不到文件,此时路径应该为“ sys.path[0] ”才对!

6、当你训练caffe网络时,你可能会好起服务器是什么配置,那么在Linux查看系统cpu个数、核心书、线程数

文章连接:https://jingyan.baidu.com/article/63acb44a81001361fcc17e21.html

7、出现Command “python setup.py egg_info” failed with error code 1

sudo easy_install -U setuptools

8、重新安装pip

sudo apt-get remove python-pip
#重新安装
sudo apt-get install python-pip python-dev build-essential

9、NVIDIA显卡算力表

NVIDA CUDA显卡计算能力对应表

猜你喜欢

转载自blog.csdn.net/qq_30460905/article/details/86238506