ubuntu20.04安装conda安装pytorch-GPU版
2023-02-09 本文已影响0人
编程研究坊
去官网查询conda安装pytorch-GPU版本命令:https://pytorch.org/get-started/previous-versions/

本文选用cuda11.3(本机已经装过cuda11.2)
一定要去掉 -c pytorch!!!!这样才能使用清华源
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3
-c后面带的是镜像地址如:
conda install torchaudio==0.9.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
检测是否安装成功
import torch
import torchvision
torch.cuda.is_available() #True即安装成功

安装后查询发现cuda还是11.2
测试CUDA和cuDNN
# CUDA TEST
import torch
x = torch.Tensor([1.0])
xx = x.cuda()
print(xx)
# cuDNN test
from torch.backends import cudnn
print(cudnn.is_acceptable(xx))
