Win10系统下使用anaconda在虚拟环境下安装CUDA及CUDNN

前排预警:不要挂梯子!!!!!使用清华源就行不然报错!!!!

解决check_hostname requires server_hostname_orange_の_呜的博客-CSDN博客错误描述在GitHub下载代码文件后使用pip install -r requirement.txt下载依赖包时出现check_hostname requires server_hostname错误解决办法原因是开启了VPN,或者局域网代理,关闭后重新下载即可。https://blog.csdn.net/m0_46268825/article/details/123192798

1、操作步骤

说明:对conda熟悉着,可以直接从(4)步开始看。

1)查看系统环境cuda版本

使用nvcc -V 可以查看系统环境下的cuda版本。

nvcc -V

2)查看版本支持

以管理员身份打开Anaconda Prompt,输入下列命令查看conda目前支持的cudatoolkit版本。(注cudatoolkit也是cuda)

conda search cudatoolkit --info

可以看到conda支持cuda10.1,很OK

3)创建虚拟环境


创建一个名为tensorflow的虚拟环境,python为3.7版本。

conda create -n tensorflow python=3.7


然后激活环境,如下图所示。

conda activate tensorflow

 4)添加源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

5)获取安装命令

Start Locally | PyTorchAn open source machine learning framework that accelerates the path from research prototyping to production deployment.https://pytorch.org/get-started/locally/

 获得命令

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

【一定要删除- c pytorch  不然巨特么慢】

conda install pytorch torchvision torchaudio cudatoolkit=11.3 

安装出现报错
【WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(140): Could not remove or rename D:\anaconda\pkgs\pytorch-1.5.0-py3.7_cuda102_cudnn7_0.tar.bz2. Please remove this file manually (you may need to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(140): Could not remove or rename D:\anaconda\pkgs\pytorch-1.5.0-py3.7_cuda102_cudnn7_0\Lib\site-packages\torch\lib\cudnn64_7.dll. Please remove this file manually (you may need to reboot to free file handles)】

解决
输入:conda install cudnn
下载安装之后再输入安装pytorch的命令即可。

6)测试是否安装成功pytorch

import torch
print(torch.__version__)
print(torch.cuda.is_available())


#True 安装成功

如果不行请进行离线安装!!!!!!!!!!!!! 


 

猜你喜欢

转载自blog.csdn.net/qq_39237205/article/details/124579697
今日推荐