win10 Anaconda3+PyTorch环境配置


破环境装一下午(我好菜)

anaconda prompt进入base环境

换源

方法一: 更改文件内容

channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

将上面内容复制到“C:\用户\你的用户名\.condarc”(windows)或者"/home/你的用户名/.condarc"(linux),即可切换为清华源

方法二: 输入下列四条指令更换清华源

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/

创建环境,使用3.7版本python,然后启动环境

conda create -n pytorch python=3.7
conda activate pytorch

进入pytorch官网,查找相应版本下载指令

网址:https://pytorch.org/get-started/locally/
在这里插入图片描述
我的版本对应下载指令为:
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge

关于cuda版本,输入nvcc --version查看在这里插入图片描述
实在是太老了…

更新下cuda

在这里插入图片描述先卸载老版本的
在这里插入图片描述
卸载完就只剩这三
在这里插入图片描述
破mx150居然支持cuda11…
在这里插入图片描述
直接下载本地安装包

下载相应版本cudnn

无脑安装cuda时遇到问题在这里插入图片描述
vs要记得关掉
安装好后环境变量已经自动配置好

下面安装cudnn

将下载的cudnn文件解压,看到里面有三个文件夹,复制文件夹里的文件到cuda的安装目录下对应文件夹中即可

检查cuda与cudnn安装

管理员身份运行cmd,进入目录
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\demo_suite

运行:
deviceQuery.exe
在这里插入图片描述
显示pass

运行:
bandwidthTest.exe
在这里插入图片描述
显示pass

nvcc --version查看版本
在这里插入图片描述

安装成功

下面就可以安装pytorch了

anaconda prompt里运行pytorch官网提供的命令:
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge

!!!在base环境可以直接安装,但是在我新建的环境pytorch里安装报错:
pytorch LoadLibrary() argument 1 must be str, not None
在这里插入图片描述
出现问题,估计是太久没更新,卸载原有anaconda后重新安装,成功
(我有罪,我上一个项目是2019年…)
在这里插入图片描述
等待安装完成

新错误

在这里插入图片描述

网上查了下,应该是网络不稳定下载超时导致

详见:
https://www.cnblogs.com/xyzluck/p/12810835.html
没急着重开,先前老提示conda更新,跑去base环境更新了下conda,实测pytorch环境无法更新
conda update conda

重试安装pytorch
在这里插入图片描述
安装成功,完结撒花

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值