Ubuntu16.04安装Caffe2(GPU+CUDA9.0+CUDNN7+Anaconda3.0+python3.6)

Caffe2官网地址:https://caffe2.ai/docs/getting-started.html?platform=ubuntu&configuration=prebuilt

创建虚拟环境,并激活:

conda create -n caffe2-3.6 python=3.6

source activate caffe2-3.6

//按照官方说法可以支持cuda8.0和cudnn5.7以上

安装cuda8.0:

sudo apt-get update && sudo apt-get install wget -y --no-install-recommends
wget "http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb"
sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb

安装cudnn6.0:

下载:https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v6/prod/8.0_20170307/cudnn-8.0-linux-x64-v6.0-tgz
sudo tar xvzf cudnn-8.0-linux-x64-v6.0.tgz -C /usr/local
sudo ldconfig

//但是我安装pytroch发现会有问题,换成cuda9.0和cudnn7

官网下载有时会失败,可以从这里下载:https://download.csdn.net/download/balixiaxuetian/10229488

sudo bash cuda_9.0.176_384.81_linux.run //最好把原来的/usr/local/cuda删除,不然可能失败

sudo mv cudnn-9.0-linux-x64-v7.solitairetheme8 cudnn-9.0-linux-x64-v7.tgz

sudo tar xvzf cudnn-9.0-linux-x64-v7.tgz -C /usr/local

更新NCCL:

git clone https://github.com/NVIDIA/nccl.git

cd nccl

make

将build/lib下文件放到/usr/local/lib,build/include下文件放到/usr/local/include

安装依赖:

sudo apt-get update
sudo apt-get install -y --no-install-recommends build-essential git libgoogle-glog-dev libgtest-dev libiomp-dev libleveldb-dev liblmdb-dev libopencv-dev libopenmpi-dev libsnappy-dev libprotobuf-dev openmpi-bin openmpi-doc protobuf-compiler python-dev python-pip python-pydot libgflags-dev cmake
sudo pip install flask graphviz hypothesis jupyter matplotlib pydot python-nvd3 pyyaml requests scikit-image scipy setuptools tornado future numpy protobuf typing Cython

CUDA library/usr/lib/x86_64-linux-gnu/libcuda.so
export CMAKE_PREFIX_PATH="$(dirname $(which conda))/../"
# Install basic dependencies
conda install numpy pyyaml mkl mkl-include setuptools cmake cffi typing
conda install -c mingfeima mkldnn
# Add LAPACK support for the GPU
conda install -c pytorch magma-cuda90

conda安装(其他方式在我这都失败):

conda install pytorch-nightly -c pytorch

测试:

# To check if Caffe2 build was successful
python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"

# To check if Caffe2 GPU build was successful
# This must print a number > 0 in order to use Detectron
python -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())'

参考链接:

https://pytorch.org/get-started/locally/

https://caffe2.ai/docs/getting-started.html?platform=ubuntu&configuration=compile

https://developer.nvidia.com/rdp/cudnn-archive

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=runfilelocal

https://github.com/pytorch/pytorch

https://blog.csdn.net/ksws0292756/article/details/80120561

http://pressahead.blog.163.com/blog/static/105913412010013102235204/

https://blog.csdn.net/e01528/article/details/80636867

https://blog.csdn.net/mathlpz126/article/details/78237005

https://blog.csdn.net/weixin_39800144/article/details/78205617

https://blog.csdn.net/eddy_zheng/article/details/52910249

http://www.cnblogs.com/harvey888/p/5465452.html

https://blog.csdn.net/zhangjunhit/article/details/76532196

https://blog.csdn.net/yasi_xi/article/details/7802733

https://blog.csdn.net/russle/article/details/4482784

http://blog.sina.com.cn/s/blog_c3c116470102wlv5.html

你可能感兴趣的:(计算机视觉和多媒体计算,工具)