2019.12.05 caffe(gpu)安装
参考网址:
教程1:
weiliu89/caffegithub.com教程2:
https://blog.csdn.net/yggaoeecs/article/details/79163789blog.csdn.net环境:Ubuntu16.04+cuda10.0
安装过程:
git clone https://github.com/weiliu89/caffe.git
cd caffe
cp Makefile.config.example Makefile.config
make -j8
之后报错:
打开并修改配置文件Makefile.config,按照教程2 https://blog.csdn.net/yggaoeecs/article/details/79163789
接着报错:
解决方法是在Makefile.config中添加#include<cudnn.h> 或者 #USE_CUDNN := 1
0.0是我刚刚改错了,我以为自己用到cudnn,去掉了这行的注释
再次make,报错如下:
解决参考:
https://blog.csdn.net/u013524303/article/details/81609643
nvcc fatal : Unknown option ‘fPIC’
nvcc本身不支持-fPIC编译参数,但是却提供了-Xcompiler用途上,使用nvcc -h可以发现,这是提供了向低级编译工具(gcc)传递编译参数的功能,因此在编译.cu文件时,在nvcc后加上 -shared -Xcomplier -fPIC 即可链接。
我遇到的错误是参考的博客中,在添加
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
-Xcompiler之前少了一个空格
修改之后, make clean,再次make
这个注释掉Makefile.config中的这一行就可以了,如下:
CUDA_ARCH := #-gencode arch=compute_20,code=sm_20
之后报错如下:
参考解决:https://github.com/BVLC/caffe/issues/1761
在caffe文件夹下:
protoc src/caffe/proto/caffe.proto --cpp_out=.
mkdir include/caffe/proto
mv src/caffe/proto/caffe.pb.h include/caffe/proto
之后运行,报错如下:
之后参考网上解决方案:
make clean
cd caffe
mkdir build
cd build
cmake ..
make all -j8
显示安装成功:
接着make runtest,测试成功:
之后按照教程2进行MNIST数据集测试,显示可以成功训练
之后在Ubuntu环境下,打开python解释程序,输入import caffe时,出现如下错误:
解决参考:
https://blog.csdn.net/u010417185/article/details/53559107blog.csdn.net最终可以把caffe中的python导入到解释器中。
附注:
1.问题解决,配置tensorflow-gpu1.15.0却不能调用gpu?的情况:
安装教程参考:
干货|TensorFlow开发环境搭建(Ubuntu16.04+GPU+TensorFlow源码编译)mp.weixin.qq.com主要解决方法如下:
vim ~/.bashrc
在最后:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-10.0/lib64:/usr/local/cuda-10.0/extras/CUPTI/lib"
export CUDA_HOME=/usr/local/cuda-10.0
之后 source ~/.bashrc
就可以成功调用gpu
安装步骤(简版):
Example environment setup for training can be created with Miniconda:
1.wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
source ~/.bashrc
2.For CPU usage:
conda create -n tfcpu
conda activate tfcpu
pip install tensorflow==1.15.0 tqdm
3.For GPU usage:
conda create -n tensorflow_gpu python=3.6
conda activate tensorflow_gpu
pip install tensorflow-gpu==1.15.0 tqdm
2.cmake安装新版本
Solution:
- Check your current version with cmake --version
- Uninstall it with sudo apt remove cmake(or)
- Visit https://cmake.org/download/ and download the latest binaries
- In my case cmake-3.6.2-Linux-x86_64.sh is sufficient copy the binary to /opt/
4. chmod +x /opt/cmake-3.*your_version*.sh (chmod makes the script executable)
5. sudo bash /opt/cmake-3.*your_version.sh* (you'll need to press y twice)
The script installs to /opt/cmake-3.*your_version* so in order to get the cmake command, make a symbolic link:
6. sudo ln -s /opt/cmake-3.*your_version*/bin/* /usr/local/bin
Test your results with cmake --version