成功版Cuda10.2+Cudnn8.0+Anaconda3+Pytorch1.7.1+Windows10

        随着人工智能理论的火热,加之硬件设备的提升如GPU算力的增强等,越来越多的高校学生、科研工作者们选择了深度学习的神经网络。技术日新月异,模型迭代优化,网络不断加深。

        然而在配置相关GPU环境方面却时常困扰很多人,查询许久,百人百言。其实并没有那么困难,跟着我一步一步走,保证无差错配置成功。本文取自个人经验,全程干货,深度阐述了在配置环境的步骤和可能遇到的错误。

一、准备工作

        所谓:工欲善其事必先利其器,首先下载所需的内容Anaconda3+Cuda10.2+Cudnn8.0。注意注意:cuda/cudnn/pytorch的版本一定要匹配,否则会显示无法使用GPU.

第一步:

Anaconda3下载https://www.anaconda.com下载即可。接下来为Anaconda安装镜像源:

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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
#设置搜索时显示通道地址
conda config --set show_channel_urls yes

这样使用Anaconda Prompt下载依赖的时候会快很多。

使用conda下载命令:conda install xxx

使用conda卸载命令:conda uninstall xxx

conda list 展示已经安装的依赖

第二步:

Cuda10.2         :建议去pytorch官网选择对应版本下载即可。

Cudnn8.0         :自行寻找,网上很多,如未果,评论区找我免费领取。

Follow the prompts to install Cuda10.2, and remember the installation path (it is recommended to default, select Custom and check all for the first installation; otherwise, choose streamlined installation.), the new version of cuda will automatically configure environment variables after installation. After you have downloaded these two, after decompressing cudnn, copy all the lib/bin/include files to the C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2 path and replace them with administrator privileges corresponding files.

2. Configure environment variables

Set in the path in the system variable:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\lib\x64

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\libnvvp

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\lib

At this point, your GPU configuration is complete.

third step:

Download the pytorch1.7.1 version in pycharm.

Use the following commands to check whether torch is installed, torch version, and whether cuda (GPU) can be used.

import torch
print(torch.__version__)
print(torch.version.cuda)
print(torch.backends.cudnn.version())
print(torch.cuda.is_available())

When the prompt appears on the console, it proves that the installation is successful. The GPU can be happily used.

                                               

 

3. Summary

1. According to the configuration of your computer, the version corresponding to cuda/cudnn/pytorch must be downloaded correctly.

2. The environment variable configuration is correct.

3. If you encounter a problem, calm down first, and read more about my steps. If it doesn’t work, please ask questions directly in the comment area. There is nothing difficult in the world, as long as there is a heart, I will teach it without hesitation.

At this point, you're done! How about it, it's not that difficult!

おすすめ

転載: blog.csdn.net/m0_58508552/article/details/125554130
おすすめ