Ubuntu18.4 安装Python以及pytorch
1、安装Python3.6
更新包列表
sudo apt-get update
更新已安装的包
sudo apt-get upgrade
安装python3.6
sudo apt-get install python3.6
查看安装
python3 -V
2、安装pytorch
2.1 GPU
如果需要在GPU上运行的,需要安装cuda 和 cudnn 可以参考
https://blog.csdn.net/weixin_43742276/article/details/108771017
版本根据自己的来
2.2 安装miniconda3
https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/
可以自行选择版本,复制链接下载
sudo wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py38_4.8.2-Linux-x86_64.sh
sudo chmod +x Miniconda3-py38_4.8.2-Linux-x86_64.sh
./Miniconda3-py38_4.8.2-Linux-x86_64.sh
如出现more,一直点击enter键即可.直到出现选择 ‘yes’ or ‘no’.
输入 yes
继续按enter键,执行miniconda创建和packages的安装。
在选择yes
重新开一个终端,进入base环境就可以conda操作了
如果要退出 base 环境回到系统自动的环境。
conda deactivate
如果要重启base环境,输入命令 conda activate base 即可。
2.4 安装pytorch
安装pytotch 根据自己的硬件对应版本,可以在下面链接里找相应的命令
https://pytorch.org/get-started/previous-versions/
conda install pytorch==1.5.1 torchvision==0.6.1 cudatoolkit=10.1 -c pytorch
++++++++++++++++++++++++++++++++++++++++++
更新:
有时候会发现用conda install 从清华源安装,安装的一直是cpu版本,就需要用官网提供的 pip 方法安装。 例:
pip3 install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio==0.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
++++++++++++++++++++++++++++++++++++++++++
安装成功后进入python3
成功!!!
参考链接
[1] https://blog.csdn.net/hezuijiudexiaobai/article/details/105058382
[2] https://blog.csdn.net/weixin_44354586/article/details/89683852