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

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值