在CentOS系统下安装PyTorch可以通过多种方式实现,包括使用Anaconda发行版或直接使用pip。以下是具体的安装步骤和注意事项:
安装Anaconda:
创建虚拟环境:
conda create -n pytorch python=3.8
conda activate pytorch
安装PyTorch:
conda install pytorch torchvision torchaudio cudatoolkit=11.8 -c pytorch
验证安装:
import torch
print(torch.__version__)
print(torch.cuda.is_available())
安装pip(如果尚未安装):
sudo yum install python3-pip
安装PyTorch:
pip install torch torchvision torchaudio -f https://pypi.tuna.tsinghua.edu.cn/simple
验证安装:
import torch
print(torch.__version__)
print(torch.cuda.is_available())
请注意,如果你需要使用GPU版本的PyTorch,确保你的系统上已经安装了兼容的NVIDIA GPU驱动和CUDA Toolkit。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: Docker容器在CentOS上的数据持久化