在使用RTX 5056Ti显卡进行深度学习开发时,需安装适配的PyTorch(CUDA版本),本文将分享最简安装步骤及常见依赖冲突的解决方法,亲测有效。
一、卸载原有CUDA版本的PyTorch
首先卸载已安装的PyTorch(仅针对CUDA版本,CPU版本无需此操作),避免新旧版本冲突。
二、安装适配的PyTorch与torchvision
直接通过pip安装CUDA 130版本的PyTorch和torchvision,执行以下命令即可:
bash
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu130
三、解决torchaudio版本依赖冲突
安装完成后,部分用户会遇到如下依赖冲突错误:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchaudio 2.7.1+cu118 requires torch==2.7.1+cu118, but you have torch 2.9.1+cu130 which is incompatible.
错误原因:已安装的torchaudio版本与新安装的PyTorch(cu130)版本不兼容。
解决方法:安装CUDA 130适配的torchaudio,执行命令:
bash
pip install torchaudio --index-url https://download.pytorch.org/whl/cu130
验证安装(可选)
安装完成后,可运行以下Python代码验证CUDA是否可用:
python
import torch
print(torch.cuda.is_available()) # 输出True则表示适配成功