当前位置:   article > 正文

在 ubuntu20.04 上安装 Pytorch_ubuntu20.04安装pytorch

ubuntu20.04安装pytorch

参考资料:https://www.linode.com/docs/guides/pytorch-installation-ubuntu-2004/

sudo apt update
sudo apt install nvidia-cuda-toolkit (3G)
mkdir anaconda
cd ~/anaconda
wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh
chmod +x ./Anaconda3-2020.11-Linux-x86_64.sh
sudo ./Anaconda3-2020.11-Linux-x86_64.sh
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

Scroll through the license agreement and agree to it by entering Yes. Indicate the destination directory for Anaconda. The default directory is ~/anaconda.

注意:在安装 anaconda 的时候(执行 Anaconda3-2020.11-Linux-x86_64.sh 脚本的时候),会要求你输入安装目录,这里我们不能提前 mkdir 那个目录,路径必须设定为一个不存在的路径才不会报错

TODO: here

The installer prompts you to initialize Anaconda3 by running conda init. We recommend entering yes (if you enter no, conda cannot modify your shell scripts).

You are now ready to install PyTorch and PyTorch tools using Anaconda. From the ~/anaconda directory install PyTorch:

 conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
  • 1

在我这里,conda 命令并不能使用,可以在 anaconda3/bin/ 目录下找到 conda 命令,建议设置一个软连接到 /usr/local/bin/ 里

sudo apt install python3-pip
pip3 install torch==1.9.1+cpu torchvision==0.10.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
  • 1
  • 2

如果要安装 GPU/NVIDA 库,使用如下代码

pip3 install -f torch torchvision
  • 1

end

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/849300
推荐阅读
相关标签
  

闽ICP备14008679号