首先借一下sudo
账号,登陆这台新机器。
- 登陆之后给自己建立一个新账号:
useradd zihao_wang
- 给自己改个新密码:
passwd zihao_wang
- 给自己加上
sudo
权限:
改/etc/sudoers
文件,在root ALL=(ALL:ALL) ALL
下面加上一行zihao_wang ALL=(ALL:ALL) NOPASSWD:ALL
- 然后给自己建一个主目录:
mkdir /home/zihao_wang
chown zihao_wang:zihao_wang /home/zihao_wang
- 然后把
shell
改成bash
:
usermod --shell /bin/bash zihao_wang
下面就不用sudo
啦
- 如果你和我一样使用
oh-my-zsh
,上面就改成zsh
,然后装上oh-my-zsh
(ubuntu好像不自带zsh,先用apt装一下)
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
- 然后去清华镜像站下载
Anaconda
目前最新版是https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2018.12-Linux-x86_64.sh
- 安装好
Anaconda
以后先加上清华的channel
:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
- 创建一个新的虚拟环境:
conda create -n py36 python=3.6
- 然后看看
cuda
版本:
cat /usr/local/cuda/version.txt
- 去
pytorch
官网看看怎么装:
注意这里,我们改用清华的channel
了,就把-c
去掉吧。
激活一下刚装好的环境
conda activate py36
conda install pytorch torchvision cuda80
- 然后去你原来机器上,把环境导出一下:
conda list --export > requirements.txt
这是我导出的:
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: linux-64
blas=1.0=mkl
ca-certificates=2018.03.07=0
certifi=2018.11.29=py36_0
cffi=1.11.5=py36he75722e_1
freetype=2.9.1=h8a8886c_1
intel-openmp=2019.1=144
jpeg=9b=h024ee3a_2
libedit=3.1.20170329=h6b74fdf_2
libffi=3.2.1=hd88cf55_4
libgcc-ng=8.2.0=hdf63c60_1
libgfortran-ng=7.3.0=hdf63c60_0
libpng=1.6.36=hbc83047_0
libstdcxx-ng=8.2.0=hdf63c60_1
libtiff=4.0.9=he85c1e1_2
mkl=2019.1=144
mkl_fft=1.0.10=py36ha843d7b_0
mkl_random=1.0.2=py36hd81dba3_0
ncurses=6.1=he6710b0_1
ninja=1.8.2=py36h6bb024c_1
numpy=1.15.4=py36h7e9f1db_0
numpy-base=1.15.4=py36hde5b4d6_0
olefile=0.46=py36_0
openssl=1.1.1a=h7b6447c_0
pillow=5.4.1=py36h34e0f95_0
pip=18.1=py36_0
pycparser=2.19=py36_0
python=3.6.8=h0371630_0
pytorch=0.4.1=py36_py35_py27__9.0.176_7.1.2_2
readline=7.0=h7b6447c_5
setuptools=40.6.3=py36_0
six=1.12.0=py36_0
sqlite=3.26.0=h7b6447c_0
tk=8.6.8=hbc83047_0
torchvision=0.2.1=py_2
wheel=0.32.3=py36_0
xz=5.2.4=h14c3975_4
zlib=1.2.11=h7b6447c_3
刚刚装了python
、pytorch
和torchvision
了,把这几行删掉。
-
去新机器上,把这些包装一下:
conda install --file requirements.txt
-
打开一个
python
,看看pytorch
装好没:
看来是装好了嘻嘻。