CentOS 上的 PyTorch 是支持 CUDA 的,但有几个前提和注意事项:
cpuonly 版本# 使用 conda(推荐)
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
# 或使用 pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
import torch
print(torch.cuda.is_available()) # True 表示支持
print(torch.version.cuda) # 显示的 CUDA 版本
cuda unavailable
GLIBCXX not found
docker run --gpus all pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime
如果你告诉我:
我可以给你更精确的安装建议。