前面几篇文章有写我尝试在windows下安装可以在gpu运行的pytorch的经历,但是还是没能解决False的问题,尝试转战linux。
然后接触到了jupyterlab, 是连接服务器的另一种方式,是jupyter notebook的升级版,十分优秀。
参考链接https://www.jianshu.com/p/4a483d3f09de
Anaconda的安装
- 下载
从https://repo.continuum.io/archive/index.html上下载对应版本的Anaconda。
或者到官网:https://www.anaconda.com/download/#linux选择Linux版本下载
选择好版本后:
wget https://repo.anaconda.com/archive/Anaconda3-2020.07-Linux-x86_64.sh
下载速度慢的话,可以使用国内源
- 安装
执行:
bash Anaconda3-2020.07-Linux-x86_64.sh
一路enter加yes
安装路径默认为用户目录(可以自己指定),最后需要确认将路径加入用户的.bashrc中。
为了使路径生效,执行
source .bashrc
- 卸载
1) 删除anaconda安装的文件夹
sudo rm -rf path/anaconda3
2) 修改配置文件
vim ~/.bashrc
删除语句,或者注释下面语句
export PATH=path/anaconda3/bin:$PATH
3)更新配置文件
source ~/.bashrc
创建虚拟环境
创建虚拟环境:
conda create -n torch_env python=3.8
激活虚拟环境:
conda activate torch_env
退出虚拟环境
conda deactivate
添加国内镜像
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/pytorch/
conda config --set show_channel_urls yes
CUDA的安装
各版本CUDA下载地址https://developer.nvidia.com/cuda-toolkit-archive
- 查看系统是ppc64le还是x86_64(也可以查看ubuntu版本)
uname -a
- 下载
wget https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run
- 安装(这一步在本地进行,服务器没有管理员权限,暂时搁置)
pytroch的安装
jupyterlab的安装
安装方法
conda直接安装:
conda install -c conda-forge jupyterlab
密码修改
参考网址
注意修改密码后要重启jupyterlab才能生效
注意:c.MappingKernelManager.root_dir = ‘/home/ubuntu/.jupyter_run/root’ 仍然可以注释
服务器的使用
1. 登录
Jupyter登录
- 终端输入:jupyter-lab或jupyter lab命令;
- 浏览器打开链接:xxxxxx,并输入密码。
SSH登录服务器
ssh -X usrname@address
enter passwd
2. 退出
exit
3. 使用
python3 filename.py