Torch-gpu
- anaconda 4.10.3(python3.9 base)
cuda:驱动版本==10.2.150
运行版本(驱动)==10.1.105 (441.22)
cudnn 7.6.4 (适用CUDA10.0,10.1,9.2,9.6)
(cudnn适用版本cuDNN Archive | NVIDIA Developer)
- 需要安装:(anaconda promote)
cudatoolkit:10.1
torch:1.7.1
python:3.6
提醒更新anaconda
conda update -n base -c defaults conda
创建虚拟环境pytorch
conda create -n pytorch python=3.6
官网安装pytorch(非GPU版本)
cudatoolkit选择10.2版本,其他根据代码需要的库安装。
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.2 -c pytorch
Index of /anaconda/pkgs/main/win-64/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
Index of /anaconda/cloud/pytorch/win-64/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirrory
由于使用torch.cuda.is_available()返回False:在版本都匹配的情况下,重新安装pytorch-gpu
/anaconda/cloud/pytorch/win-64/ | 重庆邮电大学开源镜像站 / CQUPT Open Source Software Mirror
需要下载:pytorch-1.7.1-py3.6_cuda101_cudnn7_0.tar.bz2
将上面的文件复制到 D:\anaconda\pkgs(anaconda安装位置\pkgs)
执行命令:
conda install --use-local pytorch-1.7.1-py3.6_cuda101_cudnn7_0.tar.bz2
--use-local代表当前路径是文件存放路径。
Tensorflow-gpu
pip install tensorflow-gpu==2.3.0 --default-timeout=100 -i https://pypi.tuna.tsinghua.edu.cn/simple
若出现以下错误
ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: 'd:\\anaconda\\envs\\riadd.aucmedi-main\\lib\\site-packages\\~umpy\\.libs\\libopenblas.XWYDX2IKJW2NMTWSFYNGFUWKQU3LYTCZ.gfortran-win_amd64.dll'
Consider using the `--user` option or check the permissions.
在pip install后面添加--user
pip install --user tensorflow-gpu==2.3.0 --default-timeout=100 -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
使用以下命令查看tensorflow-GPU是否安装成功
python
import tensorflow as tf
print('GPU',tf.test.is_gpu_available())
若显示为False,且出现以下提示,就需要在C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin(\bin)找到dll文件,复制到C:\Windows\System32
Could not load dynamic library 'cudnn64_7.dll'; dlerror: cudnn64_7.dll not found