在 ubuntu20.04 上安装 Pytorch

发布于:2023-09-16 ⋅ 阅读:(66) ⋅ 点赞:(0)

参考资料: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

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到