在Ubuntu下選擇PyTorch版本時,需要考慮多個因素,包括CUDA版本、Python版本、系統穩定性以及社區支持等。以下是一些推薦的版本和安裝步驟:
CUDA 11.3:
conda install pytorch=1.12.1 torchvision=0.13.1 torchaudio=0.12.1 cudatoolkit=11.3 -c pytorch
CUDA 12.1:
創建并激活Conda環境:
conda create -n myenv python=3.8
conda activate myenv
安裝PyTorch:
conda install pytorch=1.12.1 torchvision=0.13.1 torchaudio=0.12.1 cudatoolkit=11.3 -c pytorch
conda install pytorch=2.4.0 torchvision=0.19.0 torchaudio=2.4.0 cudatoolkit=12.1 -c pytorch -c nvidia
安裝完成后,可以通過以下命令驗證PyTorch是否安裝成功:
python -c "import torch; print(torch.__version__)"
python -c "import torch; print(torch.cuda.is_available())"
通過這些步驟和建議,您可以在Ubuntu下選擇合適的PyTorch版本,確保其與您的硬件和軟件環境兼容。