pytorch一直安装失败?

1.Anaconda安装

下载链接
直接安装,能选择添加系统路径就添加。
在这里插入图片描述
不行的话,手动添加系统环境变量:
在这里插入图片描述

2.创建环境

启动Anaconda Prompt 创建虚拟环境:
在这里插入图片描述
创建名为 pytorch 的环境,代码:

conda create -n pytorch python=3.8

创建完成后,查看是否成功:

conda info --envs

在这里插入图片描述

3.安装pytorch

激活 pytorch 环境:

conda activate pytorch

在这里插入图片描述
官网选择对应版本的安装代码,没有对应版本则去查找往期版本的:

conda install pytorch==1.13.0 torchvision==0.14.0 torchaudio==0.13.0 pytorch-cuda=11.6 -c pytorch -c nvidia

在这里插入图片描述
注意cuda版本需要与电脑显卡匹配。可用nvidia-smi 查看电脑cuda版本。
为了加速可以更改镜像下载路径,更改C:\Users\用户名路径下的.condarc文件:

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - 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
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

安装完成即可。

测试是否成功:(在pytorch环境内)

python
import torch
torch.cuda.is_available
  • 2
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值