官网下载Anaconda3-5.2.0-Linux-x86_64.sh到本地(Xshell直接拖动)
bash Anaconda3-5.2.0-Linux-x86_64.sh (yes...)
ubuntu换源(先备份)(可能用sudo)
cp /etc/apt/sources.list /etc/apt/sources.list.bak
chmod 777 /etc/apt/sources.list
vim /etc/apt/sources.list
#添加阿里源 deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse #添加清华源 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse multiverse
更新源(sudo)
apt-get update
更新软件
apt-get upgrade
创建conda环境
查看python版本
python
conda create -n pt171 python=3.6.5
查看环境
conda info -e
进入环境
source activate pt171
安装pytorch(GPU 从官网)
首先 pip install numpy(听说不装会报错?迷信一波)
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=11.0 -c pytorch
查看安装
conda list
测试是否安装成功
python import torch torch.cuda.is_available()
另:测试cuda是否安装成功
nvcc -V
安装jupyter(要在pytorch环境中)
pip install jupyter
生成notebook配置文件
jupyter notebook --generate-config
生成密码(jupyter_notebook_config.json中生成hash码)
jupyter notebook password
vim /home/yjc/.jupyter/jupyter_notebook_config.json
修改配置文件
vim /home/yjc/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip='*' c.NotebookApp.password = u'从json复制粘贴' c.NotebookApp.open_browser = False c.NotebookApp.port = 8888 c.NotebookApp.allow_remote_access = True
输入jupyter notebook启动
页面输入ip:端口号(8888)
安装opencv(在环境中)
pip install opencv-python