1. 打开终端,输入以下命令安装pip:

    sudo apt-get install python3-pip
    
  2. 安装torch:

    pip3 install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
    

    这里安装的是CPU版本的torch,如果需要安装GPU版本的torch,请将上面的命令中的“cpu”替换为“cu111”(对应CUDA 11.1版本)或“cu102”(对应CUDA 10.2版本)等。

  3. 安装完成后,可以在Python代码中使用torch了:

    import torch
    print(torch.__version__)
    
python38安装torch

原文地址: https://www.cveoy.top/t/topic/YNn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录