阅读量:3
Ubuntu与PyTorch的集成方式主要有以下两种,均需先安装Python环境:
- 使用pip安装
- CPU版本:更新系统后,直接通过pip安装PyTorch,无需额外配置CUDA。
pip3 install torch torchvision torchaudio - GPU版本:需先安装对应CUDA和cuDNN,再通过pip指定CUDA版本安装PyTorch。
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117(以CUDA 11.7为例)
- CPU版本:更新系统后,直接通过pip安装PyTorch,无需额外配置CUDA。
- 使用conda安装
- CPU版本:创建conda环境后,安装CPU版PyTorch。
conda install pytorch torchvision torchaudio cpuonly -c pytorch - GPU版本:安装时指定CUDA工具包版本,需提前安装对应CUDA和cuDNN。
conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch
- CPU版本:创建conda环境后,安装CPU版PyTorch。
安装后可通过import torch和print(torch.cuda.is_available())验证,若返回True则表示GPU加速可用。
以上就是关于“Ubuntu与PyTorch的集成方式是什么”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm