在Ubuntu上更新PyTorch,你可以按照以下步驟進行:
打開終端:
你可以通過快捷鍵 Ctrl + Alt + T 打開終端。
升級pip(如果尚未安裝或需要更新):
pip install --upgrade pip
卸載舊版本的PyTorch(可選,但推薦):
pip uninstall torch torchvision torchaudio
安裝最新版本的PyTorch: 訪問PyTorch官方網站的安裝指南,根據你的系統配置(操作系統、CUDA版本等)選擇合適的安裝命令。例如,對于Ubuntu 20.04和CUDA 11.3,你可以使用以下命令:
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
如果你使用的是Anaconda或Miniconda,可以通過conda來管理PyTorch。
打開終端:
同樣使用 Ctrl + Alt + T 打開終端。
更新conda(如果尚未安裝或需要更新):
conda update conda
升級PyTorch:
conda update pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
請根據你的CUDA版本調整 cudatoolkit 的版本號。
通過以上步驟,你應該能夠在Ubuntu上成功更新PyTorch。如果在過程中遇到任何問題,可以參考PyTorch的官方文檔或社區論壇尋求幫助。