cuda10.2
cudnn8.2.0
pytorch1.7.0
mmcv1.3.4
mmclassification0.11.0
直接搜索cuda10.2,弹出下载链接。把runfile文件和补丁文件都下载好,按照顺序【依次】sh一下,装好。
(按q翻页,accept同意协议,除了不装driver驱动,其他一路yes)
打开终端,输入”gedit ~/.bashrc“,然后再弹出的编辑器的最后,添加如下两行
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
然后source一下使它生效
source ~/.bashrc
sudo rm -rf /usr/local/cuda
sudo ln -s /usr/local/cuda-10.2 /usr/local/cuda
tar -xvf cudnn-10.2-linux-x64-v8.2.0.53.tgz
然后输入命令:
# 复制cudnn头文件
sudo cp cuda/include/* /usr/local/cuda-10.2/include/
# 复制cudnn的库
sudo cp cuda/lib64/* /usr/local/cuda-10.2/lib64/
# 添加可执行权限
sudo chmod +x /usr/local/cuda-10.2/include/cudnn.h
sudo chmod +x /usr/local/cuda-10.2/lib64/libcudnn*
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
或
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
创建虚拟环境
conda create -n torch170 python=3.7
进入虚拟环境
conda activate torch170
在官网看一下,注意版本适配,这里安装的是pytorch1.7.0
坑!!!下面这条不要用!它装的是pytorch不是torch。
conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=10.2 -c pytorch
正确安装命令:
pip install torch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0
链接: https://github.com/open-mmlab/mmcv/blob/master/README_zh-CN.md.
pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
根据cuda10.2+pytorch1.7.0,选择安装mmcv==1.3.0
pip install mmcv-full==1.3.0 -f https://download.openmmlab.com/mmcv/dist/cuda102/torch1.7.0/index.html
或者不选择mmcv版本,直接安装最新版
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cuda102/torch1.7.0/index.html
链接: https://github.com/open-mmlab/mmclassification/blob/master/docs/install.md
克隆仓库(注意这里用的是git,用https会断掉)
git clone git://github.com/open-mmlab/mmclassification.git
打开文件夹
cd mmclassification
安装
pip install -e . # or "python setup.py develop"