Ubuntu中深度学习框架Pytorch 环境(版本通用)配置流程
时间:2022-10-22 13:30:00
-
安装虚拟机 https://download3.vmware.com/software/wkst/file/VMware-workstation-full-16.0.0-16894299.exe ZF3R0-FHED2-M80TY-8QYGC-NPKYF
-
下载Ubuntu20.04 默认安装在虚拟机中
-
ubuntu换源 参考链接 https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup vi /etc/apt/sources.list sudo vi /etc/apt/sources.list sudo apt-get update
-
安装vim sudo apt-get install vim
-
安装anaconda
sudo wget https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh sh Anaconda3-2021.05-Linux-x86_64.sh -bfp #-bfp意思是全部默认安装
-
配置conda环境变量
vim ~/.bashrc 在首行输入export PATH=/home/username/anaconda3/bin:$PATH #username 是你自己的用户名
-
创建虚拟环境
conda create --name pt_18.1 python=3.8 #激活环境 conda activate pt_18.1
-
激活环境 此时可能会提示
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. To initialize your shell, run $ conda init
输入:conda init bash
重启终端,然后再次激活环境
-
在pytorch官网搜索命令 https://pytorch.org/get-started/locally/ 选择自己的平台。如果您需要的版本没有显示,请单击previous-versions找到你需要的版本
#不能使用虚拟机GPU
-
安装pytorch
linux cpu选 conda install pytorch torchvision torchaudio cpuonly -c pytorch
-
此刻 ,linux cpu pytorch环境已配好
-
开启ssh服务
sudo apt-get install openssh-server sudo ps -e |grep ssh #显示有ssh说明开启成功
-
使用ip a命令查看本机ip
ens33: flags=4163
mtu 1500 inet 192.168.140.128 netmask 255.255.255.0 broadcast 192.168.140.255 #一般开头是en是网络适配器 inet 192.168.140.128 该ip就是ubuntu的ip -
测试ssh 在win cmd中运行 ssh username@192.168.140.128 然后输入密码 能连接代表ssh已配置完成
-
在pycharm里使用Linux的conda环境
服务器账号 username@192.168.140.128 填入密码 1. pycharm添加解释器ssh interpreter 2. 选择 existing server configuration 3. 左上加号 host填192.168.140.128 用户名密码 3. Interpreter:/home/username/.conda/envs/pt_18.1/bin/python 钩上使用root权限 4. 成功 5. 性能有限只能学习用,但是跟大型gpu服务器用法一致
-
至此 已完成配置