CUDA版本
cmd
nvidia-smi
# NVIDIA-SMI 546.56 Driver Version: 546.56 CUDA Version: 12.3
nvcc --version
# nvcc: NVIDIA (R) Cuda compiler driver
# Copyright (c) 2005-2023 NVIDIA Corporation
# Built on Wed_Nov_22_10:30:42_Pacific_Standard_Time_2023
# Cuda compilation tools, release 12.3, V12.3.107
# Build cuda_12.3.r12.3/compiler.33567101_0
python版本
cmd
C:\Windows\System32>python -V
Python 3.11.5
官网选择适配版本
pen an Anaconda prompt via: Start | Anaconda3 | Anaconda Prompt
(base) C:\Users\yinwe>pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
Requirement already satisfied: mpmath>=0.19 in c:\users\yinwe\installed\anaconda3\lib\site-packages (from sympy->torch) (1.3.0)
Installing collected packages: typing-extensions, torch, torchvision, torchaudio
Successfully installed torch-2.2.1+cu121 torchaudio-2.2.1+cu121 torchvision-0.17.1+cu121
verification
python
import torch
x = torch.rand(5, 3)
print(x)
check if GPU driver and CUDA are enabled and accessible by PyTorch
>>> torch.cuda.is_available()
True