Linux子系统安装anaconda3和pytorch

安装anaconda3

  1. sh ./Anaconda3-2022.10-Linux-x86_64.sh
  2. 开始一直按 Enter,快速过完协议
  3. 之后会出现是否统一上面的协议,肯定是yes
Do you accept the license terms? [yes|no]
[no] >>>
Please answer 'yes' or 'no':'
yes
  1. 记住默认的目录/home/swift/anaconda3之后添加变量需要。然后按Enter,我这里用默认的目录,如果是自己修改的目录,需要自己记住。
Anaconda3 will now be installed into this location:
/home/swift/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/swift/anaconda3] >>>
  1. vim ~/.bashrc输入以下内容
export PATH="/home/swift/anaconda3/bin:$PATH"
  1. source ~/.bashrc
  2. 这里和真实的Ubuntu系统有点不一样,看下面的记录,这里需要手动激活conda的虚拟环境才行。
swift@LAPTOP-3N6UNIUA:/mnt/d/download/idm$ vim ~/.bashrc
swift@LAPTOP-3N6UNIUA:/mnt/d/download/idm$ source ~/.bashrc
swift@LAPTOP-3N6UNIUA:/mnt/d/download/idm$ source activate base
(base) swift@LAPTOP-3N6UNIUA:/mnt/d/download/idm$

安装pytorch

  1. 创建虚拟环境 conda create -n exer python=3.8,之后确认安装
  2. conda activate exer进入虚拟环境。
  3. 进入pytorch官网,进入历史下载
  4. 找到命令,这里我安装1.11的版本,因为我的cuda是11.3版本。
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113 -i https://pypi.doubanio.com/simple
  • 这里使用豆瓣的镜像下载,就是在官网的后面增加镜像
(exer) swift@LAPTOP-3N6UNIUA:/mnt/d/download/idm$ pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113 -i  https://pypi.doubanio.com/simple
Looking in indexes: https://pypi.doubanio.com/simple, https://download.pytorch.org/whl/cu113
Collecting torch==1.11.0+cu113
  Downloading https://download.pytorch.org/whl/cu113/torch-1.11.0%2Bcu113-cp38-cp38-linux_x86_64.whl (1637.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━╸━━━━━━━━━━━━━━━ 1.0/1.6 GB 5.6 MB/s eta 0:01:52
  • pip的速度还是很快的
  • 我的cuda信息
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:15:13_PDT_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0
  • 之后检查pytorch是否可用,在虚拟环境下面执行python,
import torch
torch.cuda.is_available()
  • 如果结果是True就是可以的。

还有我的两个文章,一个是迁移Linux子系统,一个Linux子系统安装cuda和cudnn
Linux子系统迁移教程(c盘到其他盘)
Linux子系统安装cuda和cudnn

猜你喜欢

转载自blog.csdn.net/Fly_the_start/article/details/128736623
今日推荐