Pytorch CUDA 11 Windows 10 にインストール メモ

1. CUDA 11.3 ダウンロード & インストール
developer.nvidia.com

テスト
コマンドプロンプトから実行

>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Mar_21_19:24:09_Pacific_Daylight_Time_2021
Cuda compilation tools, release 11.3, V11.3.58
Build cuda_11.3.r11.3/compiler.29745058_0


2. Pytorchインストール
コマンドプロンプトから実行

> conda update --all
> conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge

テスト

>python
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> import torch
>>> x = torch.rand(5, 3)
>>> print(x)
tensor([[0.7916, 0.8205, 0.8727],
        [0.9985, 0.6213, 0.1450],
        [0.3143, 0.1618, 0.5846],
        [0.3925, 0.1929, 0.1867],
        [0.6710, 0.9961, 0.2065]])

>>> print('CUDA:', torch.cuda.is_available())
CUDA: True