欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > Ubuntu >内容正文

Ubuntu

Ubuntu 16.04 LTS, 64bit,cuda 8, Caffe环境配置编译和安装

发布时间:2025/7/25 Ubuntu 62 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Ubuntu 16.04 LTS, 64bit,cuda 8, Caffe环境配置编译和安装 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

1 GPU设备

1.1 本人使用的GPU设备

名称: 七彩虹GTX980Ti显卡iGame980Ti烈焰战神X 6G

1.2 硬件问题

Laboratory Tested Hardware:

     Berkeley Vision runs Caffe with K40s, K20s, and Titans including models at ImageNet/ILSVRC scale. We also run on GTX series cards and GPU-equipped MacBook Pros. We have not encountered any trouble in-house with devices with CUDA capability >= 3.0. All reported hardware issues thus-far have been due to GPU configuration, overheating, and the like.

CUDA compute capability:

     如果设备的运算能力 <= 2.0, 受限于设备的性能, 可能需要减少 CUDA的线程数量 和 批处理的 大小(sizes). 你的吞吐量可能会发生变化.

 

安装后, 参照我们的 reference performance numbers 确保所有的配置是正确的.

工程问题请参照  hardware/compatibility.

 

2 GPU驱动、GPU开发工具安装、Cudnn

 

2.1 基于cuda_8.0.44_linux2.run安装

 下载地址: http://blog.csdn.net/real_myth/article/details/52724892

 

2.2 cudnn-8.0-linux-x64-v5.1.tgz

install path: /usr/local/cuda-8.0/

其中,/usr/local/cuda/是软连接,指向/usr/local/cuda-8.0/

 

3 Caffe

3.1 一般依赖

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler sudo apt-get install --no-install-recommends libboost-all-dev

CUDA: 通过apt-get 或者 NVIDIA 的 .run 包安装.NVIDIA的包一般包含最新的库和驱动版本,但是安装需要手动设置.如果通过做安装包安装,依赖库和驱动可以分别独立的安装; 驱动绑定的依赖库可能会比较旧,但是对于只使用CPU的模式可以跳过.

BLAS: 安装 ATLAS 通过 sudo apt-get install libatlas-base-dev 或者 install OpenBLAS 或者 MKL(较好的CPU性能)完成.

Python (可选): 如果使用默认的Python,用于 pycaffe接口Python头文件安装方式:sudo apt-get install python-dev.

3.2 兼容性 16.04

Ubuntu 16.04需要安装CUDA 8

Ubuntu 14.04剩余的依赖

在版本 14.04下都是依赖包的方式.

sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

Ubuntu 12.04剩余的依赖

在12.04下需要手工安装.

# glog wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz tar zxvf glog-0.3.3.tar.gz cd glog-0.3.3 ./configure make && make install # gflags wget https://github.com/schuhschuh/gflags/archive/master.zip unzip master.zip cd gflags-master mkdir build && cd build export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1 make && make install # lmdb git clone https://github.com/LMDB/lmdb cd lmdb/libraries/liblmdb make && make install

注意: glog 和最新的 gflags 版本 (2.1)不兼容, 所以要先给予 glog 编译.

 

4 编译

4.1 Makefile

现在已经具备了所有的依赖条件, 编辑你的配置文件 Makefile.config,改变你的安装路径 (you should especially uncomment and setBLAS_LIB accordingly on distributions likeCentOS / RHEL / Fedora where ATLAS is installed under/usr/lib[64]/atlas),默认的配置是可以的,但是如果你使用的是Anaconda Python,请解注释相关的行。

cp Makefile.config.example Makefile.config # Adjust Makefile.config (for example, if using Anaconda Python) make all make test make runtest

编译的时候如果要引入cuDNN加速,你需要在文件Makefile.config中解注释USE_CUDNN := 1。

如果你的电脑上没有 GPU,你应该使用CPU-only模式的Caffe,请在文件Makefile.config中解注释CPU_ONLY := 1 。

要编译 Python 和 MATLAB 包,请独立的执行make pycaffe和make matcaffe . 请务必首先在Makefile.config中配置你的MATLAB 和 Python路径!

Distribution: 运行 make distribute来创建一个包含所有的Caffe 头文件, 编译好的依赖库,二进制文件等的分布式路径,用于其他机器的配置.

Speed: 如果要快速的编译,请通过make all -j8的方式并行编译,其中8是并行编译的线程的数量(并行线程的数量最好等于你机器CPU核的数量).

到目前为止,你已经安装了Caffe, 请参照 MNIST tutorial 和 reference ImageNet model tutorial进行进一步的操作.

4.2 使用CMake (beta)编译

通过手工编辑Makefile.config的方式告诉 Caffe 寻找依赖的的位置, Caffe 也提供了一个基于 CMake的编译系统 (currently in “beta”).要求CMake 版本 >= 2.8.8. 基本的安装步骤如下:

mkdir build cd build cmake .. make allmake runtest

 

See PR #1667 for options and details.

 

 

 

总结

以上是生活随笔为你收集整理的Ubuntu 16.04 LTS, 64bit,cuda 8, Caffe环境配置编译和安装的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。