一,tensorflow安装参考:https://blog.csdn.net/u013132035/article/details/77206966
二,opencv2.4.9安装参考:https://blog.csdn.net/bernice_lying/article/details/79698190
(1)opencv2.4.9下载链接;
(2)查看当前是否安装opencv及其版本号,有则会显示版本
pkg-config –modversion opencv
(3)解压opencv2.4.9后,编译
cd opencv-2.4.9
mkdir build
cd build
#GPU版
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DCUDA_GENERATION=Kepler ..
#CPU版
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
#下面 -j几都随意,看自己电脑支持多少了 如 2 4 8 16 32
make -j2
sudo make install
(4)加动态链接库
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
(5)测试是否安装成功,如下显示版本号,成功安装
三,安装caffe,参考:https://blog.csdn.net/JasonZhangOO/article/details/54866074
(1)下载链接: https://pan.baidu.com/s/1TXEnVqobhRmHFyi4No9m3g 密码: rnky
(2)解压caffe-master,进入该解压后目录:
cp Makefile.config.example Makefile.config
(3)修改Makefile.config文件中的配置,双击打开Makefile.config文件
1)在前面,找到CPU_ONLY, 去掉CPU_ONLY前面的#号
2)配置引用文件路径(主要是HDF5的路径问题)
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/
(4)点击文件右上角保存后,执行编译
sudo make all
运行结果:
(5)测试
sudo make test
运行结果:
sudo make runtest
运行结果:
四,Pycharm环境配置caffe, 以便调用
(1)编译pycaffe接口,首先,将caffe根目录下的python文件夹加入到环境变量, 打开配置文件bashrc
sudo gedit ~/.bashrc
在最后面加入,上面安装caffe的路径:
export PYTHONPATH=/home/xiqi/PycharmProjects/Install_caffe/caffe-master/python:$PYTHONPATH
注意/home/xiqi/PycharmProjects/Install_caffe/caffe-master/python 是我的路径,这个地方每个人都不同,需要修改,保存退出,更新配置文件
依然在caffe根目录下,我的是/home/xiqi/PycharmProjects/Install_caffe/caffe-master,运行:
sudo pip install -r ./python/requirements.txt
可能报错:
pandas 0.23.3 has requirement python-dateutil>=2.5.0, but you'll have python-dateutil 1.5 which is incompatible.
networkx 2.1 has requirement decorator>=4.1.0, but you'll have decorator 4.0.6 which is incompatible.
解决办法:打开requirement.txt
注释
#python-dateutil>=1.4,<2
在运行:
sudo pip install -r ./python/requirements.txt
解决如下:
再运行:
sudo make pycaffe
(2) 在命令行下用python查看caffe框架路径,依次输入:
>>python
>>import sys
>>sys.path
可以看到第一个就是caffe安装路径:/home/xiqi/PycharmProjects/Install_caffe/caffe-master/python
接下来看别人博客上说:到pycharm中添加caffe的路径:
File->Settings->Project interpreter下添加 caffe下的python路径 /home/XXX/caffe/python
但caffe/python目录下没有python,不知如何添加,所以我采用另一种方式:用终端命令行打开Pycharm,caffe的路径自然会加到Pycharm开发环境中:
进入pycharm的安装目录后,运行: ./pycharm.sh
caffe下面没有红色线条了