admin管理员组

文章数量:1558055

1.下载最新版本的pytorch

https://pytorch/官网可以根据操作系统,选择cuda版本, 和选择conda命令还是pip命令:

例如下载最新版本的pytorch命令为:

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113

例如我的cuda11.4

# 11.3
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113

如果下载很慢使用临时镜像:
参考链接: https://blog.csdn/qq_39909808/article/details/121216315
切换镜像源:
豆瓣:

http://pypi.douban/simple/

清华:

https://pypi.tuna.tsinghua.edu/simple

阿里云:

http://mirrors.aliyun/pypi/simple/

山东理工大学:

http://pypi.sdutlinux/

中国科技大学

 https://pypi.mirrors.ustc.edu/simple/

华中科技大学:

http://pypi.hustunique/

例如下载12.1. 2.2.0版本

pip install torch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 --index-url https://download.pytorch/whl/cu121 -i https://pypi.tuna.tsinghua.edu/simple

2.pytorch历史版本下载

网址:https://pytorch/get-started/previous-versions/

3.下载完成后检测gpu是否可用

代码:

import torch
torch.cuda.is_available()  

输出为ture表示gpu可用
只是检测CUDA是否安装正确并能被Pytorch检测到,并没有说明是否能正常使用,要想看Pytorch能不能调用cuda加速,还需要简单的测试一下:

a=torch.Tensor([1,2])
a=a.cuda()
a

本文标签: 版本历史Pytorch