可以,CentOS 完全可以安装 GPU 版 PyTorch,但有一些前提和注意事项。
# 安装 miniconda 后
conda create -n torch python=3.10
conda activate torch
# 安装 GPU 版 PyTorch(自动包含 CUDA)
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
✅ 优点:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
需提前确认:
nvidia-smi
nvcc --version
import torch
print(torch.cuda.is_available()) # True
print(torch.version.cuda) # 例如 12.1
torch.cuda.is_available() 返回 False原因通常是:
建议:
✅ CentOS 可以装 GPU 版 PyTorch
✅ 最稳妥方式:conda + PyTorch CUDA 包
✅ 关键是:NVIDIA 驱动正常 + 版本匹配
如果你愿意,可以告诉我:
我可以给你一份精确安装命令。