是的,CentOS支持PyTorch。您可以通過多種方式在CentOS系統上安裝PyTorch,具體取決于您是否需要GPU支持。以下是詳細的安裝步驟:
sudo yum update -y
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
安裝過程中,您需要接受許可協議、選擇安裝路徑等。完成后,重啟您的shell或終端。
conda create -n torch_env python=3.8
conda activate torch_env
conda install pytorch torchvision torchaudio cpuonly -c pytorch
conda install pytorch torchvision torchaudio cudatoolkit=your_cuda_version -c pytorch
請將 your_cuda_version
替換為您的系統上安裝的CUDA版本,例如 cudatoolkit11.1
。
python -c "import torch; print(torch.__version__)"
print(torch.cuda.is_available())
如果一切正常,您應該能看到PyTorch的版本號以及CUDA是否可用(取決于您的系統配置)。