Win10+Cuda+Pytorch


1. 流程

1.1 打开torch官网

https://pytorch.org/get-started/locally/

xxx

1.2 上图会告诉下载的Cuda tookit 版本,以及如何下载torch,torchvision

1.3 安装cuda tookit

https://developer.nvidia.com/cuda-11.3.0-download-archive

1.4 安装torch,torchvision

pip3 install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio===0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
如果网不好,建议先从https://download.pytorch.org/whl/cu113/torch_stable.html, 本地安装

2. 验证

import torch

print(torch.__version__)
print(torch.cuda.is_available())

x = torch.randn(1)
if torch.cuda.is_available():
    device = torch.device("cuda")
    y = torch.ones_like(x, device=device)
    x = x.to(device)
    z = x + y
    print(z)
    print(z.to("cpu", torch.double))