溫馨提示×

Ubuntu PyTorch有哪些常用命令

小樊
54
2025-08-07 18:48:52
欄目: 智能運維

以下是一些Ubuntu下PyTorch的常用命令:

安裝命令

  • 使用pip安裝CPU版本pip3 install torch torchvision torchaudio
  • 使用pip安裝CUDA版本(以CUDA 11.3為例)pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
  • 使用conda安裝CPU版本conda install pytorch torchvision torchaudio cpuonly -c pytorch
  • 使用conda安裝CUDA版本(以CUDA 11.3為例)conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

驗證命令

  • Python交互式查詢:進入Python交互環境,輸入import torch,然后print(torch.__version__)可查看版本,print(torch.cuda.is_available())可查看CUDA是否可用。
  • 終端直接查詢python -c "import torch; print(f'當前版本: {torch.__version__}')" ,或pip show torch | grep Version。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女