安装日期:2025年04月23日 (安装时50系显卡只支持Cuda12.8及Torch2.8)
1. 在Anaconda中创建相关虚拟环境
注:Torch2.8需要python版本大于等于3.9
2. Cuda安装
conda install cuda-toolkit=12.8 cuda-nvcc=12.8 cuda-compiler=12.8 -c nvidia
3. Cudnn安装
conda install cudnn -c nvidia
4. Pytorch安装
由于目前50系刚出不久,Pytorch只适配了Preview(Nightly)版本。常规的Stable版不能用。装老版本Pytorch会提示如下:
参考:
英伟达新一代GPU架构(50系列显卡)PyTorch兼容性解决方案_50系支持cudatool-CSDN博客
GTX 50系显卡cuda、pytorch环境配置_cuda12.8对应的pytorch-CSDN博客
但是用上图的pip指令直接安装,会出现哈希值校验失败问题。
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them. torchvision from https://download.pytorch.org/whl/nightly/cu128/torchvision-0.22.0.dev20250422%2Bcu128-cp310-cp310-win_amd64.whl: Expected sha256 8ee0514d2cddf2b615ce0a85415d9c98f99e98cbd185c22d2a23e2d849dce06e Got 0bf6ad5fc142196eb0559a44a47b9787e97a7777df9140f74474f262aa17fe9f
所以改为从官网下载whl文件然后手动安装的方式。需要下载torch、torchvision、torchaudio。
Cuda12.8适配的torch先行版本为Torch2.8(2025.04.23)
Pytorch官网:
对应版本下载网址:
https://download.pytorch.org/whl/nightly/cu128
4.1. torch安装
将ananconda切换到对应文件下载地址
pip install -i https://mirrors.cloud.tencent.com/pypi/simple torch-2.8.0.dev20250421+cu128-cp310-cp310-win_amd64.whl
(安装本地whl文件的时候,从给定的网址寻找相关依赖)
4.2. torchvision安装
pip install -i https://mirrors.cloud.tencent.com/pypi/simple torch-2.8.0.dev20250422+cu128-cp310-cp310-win_amd64.whl
4.3. torchaudio安装
pip install -i https://mirrors.cloud.tencent.com/pypi/simple torchvision-0.22.0.dev20250422+cu128-cp310-cp310-win_amd64.whl
其中,torchvision和torchaudio的版本需要比torch的版本晚。我这里安装的是晚一天的。
否则会提示:
INFO: pip is looking at multiple versions of torchvision to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement torch==2.8.0.dev20250410+cu128 (from torchvision) (from versions: 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.4.0, 2.4.1, 2.5.0, 2.5.1, 2.6.0)
ERROR: No matching distribution found for torch==2.8.0.dev20250410+cu128
5. 验证测试
在安装完torch、torchaudio、torchvision之后
- 输入python
- 输入import torch
- 输入torch.cuda.is_available()
- 如果显示为True 证明安装成功