在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的版本。