主要按照官网上的提示:https://caffe2.ai/docs/getting-started.html?platform=ubuntu&configuration=prebuilt
首先是安装cuda,cudnn,nccl
cuda和cudnn教程较多
--------------------------------------------------------------------------------------------------------------------------------------------------------------
The following steps describe how to build a cuDNN dependent program. Choose the installation method that meets your environment needs. For example, the tar file installation applies to all Linux platforms. The debian installation package applies to Ubuntu 14.04 and 16.04.
$ tar -xzvf cudnn-9.0-linux-x64-v7.tgz
$ sudo 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 /usr/local/cuda/lib64/libcudnn*
sudo dpkg -i nccl-repo-.deb
sudo dpkg -i nvidia-machine-learning-repo-.deb
sudo apt update
sudo apt install libnccl2 libnccl-dev
sudo apt-get install libnccl2=2.0.0-1+cuda8.0 libnccl-dev=2.0.0-1+cuda8.0Refer to the download page for exact package versions.
---------------------------------------------------------------------------------------------------------------------------------------------------
接下来开始安装
If you do not have a GPU:
conda install -c caffe2 caffe2
For GPU support you will need CUDA, CuDNN, and NCCL. These must be installed from Nvidia’s website.
For Caffe2 with CUDA 9 and CuDNN 7 support:
conda install -c caffe2 caffe2-cuda9.0-cudnn7
For Caffe2 with CUDA 8 and CuDNN 7 support:
conda install -c caffe2 caffe2-cuda8.0-cudnn7
按照官网上的建议:
安装caffe2之前最好新建一个anaconda环境
参考网页:https://conda.io/docs/user-guide/tasks/manage-environments.html
Use the Terminal or an Anaconda Prompt for the following steps.
To create an environment:
conda create --name myenv
NOTE: Replace myenv with the environment name.
When conda asks you to proceed, type y:
proceed ([y]/n)?
This creates the myenv environment in /envs/. This environment uses the same version of Python that you are currently using, because you did not specify a version.
完成后,进入打开caffe2的方法是:
首先激活caffe2的环境
比如我的:
然后进入python:
最后import caffe2以测试是否成功