快速安装GPU版本PyTorch(pip/阿里云/CUDA 12.1)

1. 安装cuda 12.1版本pytorch

pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 -f https://mirrors.aliyun.com/pytorch-wheels/cu121

2. 验证是否安装成功

python
>>> import torch
>>> torch.cuda.is_available()
True

3. 其他版本尝试

pip install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 -f https://mirrors.aliyun.com/pytorch-wheels/cu121
pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 -f https://mirrors.aliyun.com/pytorch-wheels/cu121
pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 -f https://mirrors.aliyun.com/pytorch-wheels/cu121

特别注意:这里针对的是cuda 12.1版本,若需其他版需查看pytorch历史版本对应torchvision、torchaudio版本;同时链接“https://mirrors.aliyun.com/pytorch-wheels/cu121”中"cu121"一般表示cuda 12.1,需要注意对应。

4. 查看本机cuda版本
# 方法1
nvidia-smi
# 方法2
nvcc -V

注:一般安装pytorch版本对应cuda版本,不能超过以上命令查阅得到cuda版本。

5. Pytorch官网(网址

https://pytorch.org/

注:可以点击历史版本,查看老版本torch对应torchvision和torchaudio版本。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值