环境准备
- 显卡:双 RTX 3090
- 系统:WSL Ubuntu
- Python: 3.12.4
- Conda: 24.5.0
- CUDA: 12.4
- PyTorch: 2.6.0
一、准备工作
首先,在 https://developer.nvidia.com/cuda-gpus 查看您的 GPU 是否支持 CUDA。
保证当前 Linux 版本支持 CUDA。在命令行中输入:
uname -m && cat /etc/*release
输出如下,不一定完全一样,类似即可:

检查是否安装了 gcc。在命令行中输入 gcc --version,应当看到类似的输出:

二、PyTorch 和 CUDA 安装
使用官网版本 2.6.0,官网链接:Previous PyTorch Versions,箭头一栏可以看到历史版本。


根据其指令安装对应版本:
# ROCM 6.1 (Linux only)
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/rocm6.1
# ROCM 6.2.4 (Linux only)
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/rocm6.2.4
# CUDA 11.8
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu118
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu124
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu126
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cpu






