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 /usr/lib/x86_64-linux-gnu/hdf5/serial4、cuda8.0编译器问题
打开/usr/local/cuda/include/host_config.h
注释掉:
error -- unsupported GNU version! gcc versions later than 5.3 are not supported!
结果如下:
#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 3)
//#error -- unsupported GNU version! gcc versions later than 5.3 are not supported!
#endif /* __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 1) */
5、遇到prototuf等编译问题:
build_release/lib/libcaffe.so: undefined reference to 'google::protobuf::io::CodedOutputStream::WriteVarint64ToArray(unsigned long long, unsigned char*)'主要是因为我们直接采用命令apt-get install 安装prototuf是比较老旧的版本,而ubuntu16.04比较新,所以我们需要卸载prototuf,然后自己在自己的电脑上编译安装。
(1)于是先卸载原有版本:
sudo apt-get autoremove libprotobuf-dev protobuf-compiler(2)从github下载protobuf
(3)打开protobuf文件目录进行编译安装,具体过程如下
编译过程过下:
A、输入命令:
sh auto*.sh生产configure文件。这步可能遇到的错误:
configure.ac:64: error: possibly undefined macro: AC_PROG_LIBTOOL
那么输入命令:
sudo apt-get install libtool
然后在次运行:
sh auto*.sh
B、按照顺序,依次输入如下命令:
./configure
make -j8
make check
make install
完成安装。
C、protobuf配置环境变量.
打开profile文件:
sudo vim /etc/profile
添加:
export PATH=$PATH:/usr/local/protobuf/bin/
export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig/<保存退出,然后输入命令:
source /etc/profileD、配置动态链接库
打开配置文件ld.so.conf:
sudo vim /etc/ld.so.conf添加:
/usr/local/protobuf/libE、更新配置
sudo su
ldconfig6、caffe编译:
make all -j8
make pycaffe
OK,万事大吉,打完收工。
四、tensorflow
以前的安装方法:
sudo apt-get install python-pip python-dev
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl
sudo pip install --upgrade $TF_BINARY_URL出现错误:
libcudart.so.7.5: cannot open shared object file: No such file or directory
主要原因是上面的tensoftlow*.whl是cuda7.5编译好的,导致我们不能直接用。因此我们接着要自己编译才行。
1、先装jdk
sudo apt-get update
sudo apt-get install default-jre
sudo apt-get install default-jdk2、安装编译工具Bazel
echo "deb [arch=amd64] stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.listcurl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add -sudo apt-get update && sudo apt-get install bazel
3、下载tensorflow并编译
./configure遇到错误:
Can't find swig. Ensure swig is in $PATH or set $SWIG_PATH.安装swig:
sudo apt-get install swig
4、在tensorflow安装的时候,没有找到可以忽略使用cudnn的选项,一直提示如下错误:
Please specify the location where cuDNN library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
Invalid path to cuDNN toolkit. Neither of the following two files can be found:
/usr/local/cuda-8.0/lib64/libcudnn.so
/usr/local/cuda-8.0/libcudnn.so
所以没办法,只能把cudnn也给安装了。首先到官网下载cuda8.0对应的cudnn:
cudnn-8.0-linux-x64-v5.0-ga.tgz
tar -zxvf cudnn-8.0-linux-x64-v5.0-ga.tgzsudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*安装完毕后,就接着前面的工作tensorflow的安装
5、输入.configure,然后一路回车、或者选择yes。
6、这是心酸,原来tensorflow官网给了从源码安装的教程:install from sources
https://www.tensorflow.org/versions/r0.9/get_started/os_setup.html
参考文献:
Ubuntu 16.04下Matlab2014a+Anaconda2+OpenCV3.1+Caffe安装
Ubuntu 16.04系统下CUDA7.5配置Caffe教程
Caffe + Ubuntu 14.04 64bit + CUDA 6.5 配置说明
Caffe配置简明教程 ( Ubuntu 14.04 / CUDA 7.5 / cuDNN 5.1 / OpenCV 3.1 )