在Ubuntu系統中,你可以通過以下幾種方法來查看PyTorch的版本:
python
或 python3
啟動Python解釋器。import torch
print(torch.__version__)
這將輸出當前安裝的PyTorch版本。
python -c "import torch; print(torch.__version__)"
或者,如果你使用的是Python 3,可以使用:
python3 -c "import torch; print(torch.__version__)"
這將直接在終端中輸出PyTorch的版本號。
如果你是通過pip或conda安裝的PyTorch,你可以查看安裝日志或相關文檔來確認版本信息。
pip show torch
在輸出的信息中,你可以找到版本號。
conda list torch
在輸出的信息中,你也可以找到版本號。
pip install torch torchvision torchaudio
或者,如果你使用的是conda:
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
通過以上方法,你應該能夠輕松地在Ubuntu系統中查看PyTorch的版本。