一、ubuntu安装Anaconda3
-
下载安装包
wget https://repo.continuum.io/archive/Anaconda3-5.3.1-Linux-x86_64.sh
-
进入安装包目录,安装
bash Anaconda3-5.3.1-Linux-x86_64.sh
-
配置环境
#打开.bashrc文件 nano ~/.bashrc #在最后添加变量 export PATH=~/anaconda3/bin:$PATH #重启环境变量 source ~/.bashrc
-
查看安装结果
conda info
二、ubuntu卸载Anaconda3
-
删除Anaconda3文件夹
rm -rf ~/anaconda3
-
删除相关隐藏文件
rm -rf ~/.condarc ~/.conda ~/.continuum
-
在环境变量中删除Anaconda3
#打开.bashrc文件 nano ~/.bashrc
-
更新环境变量
source ~/.bashrc
三、Anaconda3入门使用
-
创建环境
conda create --name 环境名 python=型号
-
激活环境
conda activate 环境名
-
退出环境
conda deactivate
-
查看已安装环境信息
conda env list
-
删除环境
conda env remove --name 环境名
-
查看已安装的包
conda list
-
搜索包
conda search 包名
-
安装包
conda install 包名1 包名2 ...
-
卸载包
conda remove 包名1 包名2
-
更新包
conda upgrade 包名 #更新所有包 conda upgrade --all
-
保存环境信息到environment.yaml文件中
conda env export > environment.yaml
-
通过environment.yaml文件创建环境
conda env create -f environment.yaml
四、配置深度学习环境
-
安装tensorflow
#安装cpu版本的 conda install tensorflow==2.3 #安装gpu版本的 conda install tensorflow-gpu==2.3
-
安装pytorch
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 -c pytorch
-
安装显卡驱动
#获取显卡驱动信息 ubuntu-driver devices #安装驱动 sudo apt install nvidia-driver-版本号 #查看显卡状态 nvidia-smi
-
安装cuda和cudnn,现在新版的anaconda都会自带的,不用单独安装
五、安装和配置Jupyter Notebook
-
安装jupyter notebook
conda install jupyter notebook
-
生成jupyter notebook配置文件,存放在/home/ubuntu/.jupyter/jupyter_notebook_config.py
jupyter notebook --generate-config
-
设置jupyter notebook访问密码,需要记住
jupyter notebook password
-
生成访问密码的hash值
#进入python环境 python #得到访问密码的hash值,需要复制下来,等会需要用 >>>from notebook.auth import passwd >>>passwd()
-
修改配置文件,把#去掉,c要顶格
#c.NotebookApp.allow_remote_access = True #c.NotebookApp.ip='*' #c.NotebookApp.open_browser = False #c.NotebookApp.password = 访问密码的hash值,带单引号 #c.NotebookApp.port = 8888 #c.NotebookApp.terminals_enabled = True
-
运行jupyter notebook,外机需要加上参数(本机可以不加),否则会被拒绝访问
jupyter notebook --ip=0.0.0.0
-
远程访问
服务器的ip:端口号
六、安装配置code-server
-
下载code-server压缩包
wget https://github.com/coder/code-server/releases/download/v4.7.1/code-server-4.7.1-linux-amd64.tar.gz
-
解压code-server压缩包
tar -zxvf code-server-4.7.1-linux-amd64.tar.gz
-
执行code-server
cd /code-server-4.7.1-linux-amd64/bin ./code-server
-
在后台运行命令
nohup ./code-server &