博主:粉色ku衩子
主题:win10 + pycharm community + cuda 10.0 + cudnn 7.6.4 + pytorch -gpu + NVIDIA GeForce RTX 2060 + anaconda
最近博主更换电脑需要重装相关的应用软件,就顺便记录了pycharm + pytorch -gpu安装过程,大家可以拿去参考一下。
如果有什么问题欢迎大家留言告诉我,我会尽快答复大家,谢谢!
一、
pycharm community下载链接: https://www.jetbrains.com/pycharm/download/#section=windows
CUDA Toolkit : https://developer.nvidia.com/cuda-10.0-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal
cudnn 7.6.4 :https://developer.nvidia.com/rdp/cudnn-archive
我用的是CUDA10.0,cuDNN v7.6.4 对应CUDA 10.0。下载之后,将CUDNN压缩包里面的bin、clude、lib文件直接复制到CUDA的安装目录下,直接覆盖安装即可。
二、pytorch -GPU安装
刚开始我去官网下载pytorch -gpu,下载速度及其缓慢,时不时还下载失败,也尝试更换源,都不行。在这里提供另一种下载方式,大家可以尝试以下。
查看当前源:
conda config --show channels
更换源:
1、清华源:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/
2、腾讯源
conda config --add channels https://mirrors.cloud.tencent.com/anaconda/pkgs/free/
conda config --add channels https://mirrors.cloud.tencent.com/anaconda/pkgs/main/
conda config --add channels https://mirrors.cloud.tencent.com/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.cloud.tencent.com/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.cloud.tencent.com/anaconda/pkgs/pro/
移除源:
1、清华源
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/
2、腾讯源
conda config --remove channels https://mirrors.cloud.tencent.com/anaconda/pkgs/free/
conda config --remove channels https://mirrors.cloud.tencent.com/anaconda/pkgs/main/
conda config --remove channels https://mirrors.cloud.tencent.com/anaconda/cloud/conda-forge/
conda config --remove channels https://mirrors.cloud.tencent.com/anaconda/cloud/pytorch/
conda config --remove channels https://mirrors.cloud.tencent.com/anaconda/pkgs/pro/
博主采用的下载方式:
1、找到Anaconda的Environments,然后点击base(root),再打开Open Terminal,添加清华源。
2、用下面的命令行,用来查看pytorch相关的可下载资源。大家可以看到Platforms和Builds两列的值,Platforms意思是该安装包可以安装的具体系统,linux—64表示系统linux64可以下载这个包,win-64表示系统windows64可以安装这个包,Builds意思是与该pytorch安装包相对应的python、cuda、cudnn的版本。大家根据自己的实际情况来选择就行。
anaconda search -t conda pytorch
在这里我我选择的是anaconda/pytorch ,然后用下面的命令来下载安装这个包。大家选择的时候,把包的名字(例如:Esri/pytorch)中的“/”替换为空格,并添加到conda install -c https://conda.anaconda.org/后面就行。
conda install -c https://conda.anaconda.org/anaconda pytorch
error:
如果出现Conda - Downloaded bytes did not match Content-Length 这样的错误,可以尝试设置下载的timeout,然后再下载。
conda config --set remote_read_timeout_secs 600.0
测试:
安装完成后,用下面的代码查看是否安装成功。若输出为True则安装成功,否则表示安装失败。
import torch print(torch.cuda.is_available()