可以的,Ubuntu 是完全可以运行 PyTorch 的,而且这是最常用、最推荐的环境之一。
pip install torch torchvision torchaudio
先确认:
nvidia-smi
然后安装对应 CUDA 版本(例如 CUDA 12.1):
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
官网可选择版本:
https://pytorch.org/get-started/locally/
conda create -n pytorch python=3.10
conda activate pytorch
pip install torch
import torch
print(torch.__version__)
print(torch.cuda.is_available())
如果你愿意,可以告诉我:
我可以给你更具体的安装方案。