在 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

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

在我这里,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

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

pip3 install -f torch torchvision

end

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值