在 CentOS 上安装和使用 PyTorch,最权威、靠谱的教程来源如下(按推荐顺序):
PyTorch 官网安装向导
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
如果你在 CentOS 上没有 root 权限,强烈推荐 Miniconda:
# 下载
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
# 创建环境
conda create -n torch python=3.10
conda activate torch
# 安装 PyTorch
conda install pytorch torchvision torchaudio cpuonly -c pytorch
CentOS PyTorch 安装sudo yum install -y python3-devel gcc cmake
PyTorch 官方安装页 + Conda + CentOS 基础命令,就是最稳的教程组合。
如果你愿意,我可以: