在Debian上選擇PyTorch版本,需結合Python版本、CUDA支持、項目需求等因素,以下是具體建議:
python3 --version,若版本過低需升級。pip install torch torchvision torchaudio。pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117。
conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch。nvidia-smi,確認已安裝的CUDA版本(如11.7、12.0)。pip install torch==2.0.0+cu117(需指定版本號,避免自動安裝不兼容版本)。pip install torch==2.1.0+cu120。import torch
print("PyTorch版本:", torch.__version__)
print("CUDA是否可用:", torch.cuda.is_available())
if torch.cuda.is_available():
print("CUDA版本:", torch.version.cuda)
參考來源: