在CentOS上搭建PyTorch環境,可以按照以下步驟進行:
下載并安裝Anaconda
bash Anaconda3-xxxx.xx-Linux-x86_64.sh
創建并激活虛擬環境
conda create -n pytorch_env python=3.8
conda activate pytorch_env
安裝PyTorch
conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch
conda install pytorch torchvision torchaudio cpuonly -c pytorch
驗證安裝
import torch
print(torch.__version__)
更新pip
pip install --upgrade pip
安裝PyTorch
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117
pip install torch torchvision torchaudio
驗證安裝
import torch
print(torch.__version__)
gcc
、make
、cmake
等。通過以上步驟,你應該能夠在CentOS上成功搭建PyTorch環境。