在远程服务器安装anoconda并创建tensorflow-gpu环境并运行jupyter

在远程服务器安装anaconda并创建tensorflow-gpu环境并运行jupyter
**

一、anaconda的安装

**
1.点击清华源Anaconda找到对应系统的Anaconda版本并下载到本地
Anaconda3-2020.07-Linux-x86_64.sh
2.通过winscp上传到远程服务器
3.安装Anaconda.sh脚本文件
3.1 在服务器里面打开终端,输入ls,找到对应文件:
Anaconda3-2020.07-Linux-x86_64.sh
3.2 在Linux里面.sh文件是可执行的脚本文件,需要用命令bash来进行安装:

bash Anaconda3-2020.07-Linux-x86_64.sh

4.然后按"Enter"或输入"yes"来进行安装设置

5.安装完成
6.导入环境变量

vim ~/.bashrc

7.在最后添加语句

export PATH=/home/user_name/anaconda3/bin:$PATH

8.更新配置文件

source ~/.bashrc

Anaconda安装与环境变量设置成功,conda命令已可用
9.设置清华源

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/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --set show_channel_urls yes

二、tensorflow-gpu的安装

1.创建tensorflow-gpu环境

conda create -n tf python==3.7

2.激活环境

conda activate tf

3.安装cudatoolkit

conda install cudatoolkit==11.2.2

4.安装cuDNN

conda install cudnn=8.1

5.安装tensorflow-GPU

pip install tensorflow-gpu==2.5.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

6.至此,Tensorflow-GPU版本已经安装成功,现在需要测试可用不可用。
在激活环境中输入python以进入python环境。
然后输入import tensorflow as tf可见如下:

在这里插入图片描述

再输入tf.test.is_gpu_available(),若最后为True表示GPU可用,证明已经成功安装Tensorflow-GPU版本,如下图:
在这里插入图片描述

三、jupyter的使用

1.安装jupyter

pip install jupyter

-若要卸载jupyter,使用pip uninstall jupyter是卸不掉jupyter的,我们可以使用下面的命令卸载jupyter:

pip install pip-autoremove
pip-autoremove jupyter -y

2.生成配置文件:

jupyter notebook --generate-config

3.生成密码(后续配置文件,登录时候需要)

输入 python #进入python终端

>>>from IPython.lib import passwd
>>>passwd()
Enter password:
Verify password:
'sha1:1caed79badce:7e6d8261d400aec9a1cb60c8b6f5d14cb0d62d16' #记录下这个密码来,后面修改配置文件要用
>>>exit()

4.修改默认配置文件

vim ~/.jupyter/jupyter_notebook_config.py

5.输入i进入开发者模式,将一下代码粘贴进去

c.NotebookApp.ip='your host ip'  #10.10.10.10  #可以用hostname -i 或者hostname -I查看,或者host -i,host -I
c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #随便指定一个端口,8899等等

6.编辑结束,按ESC 键 跳到一般模式;
:wq 保存文件并退出vi 编辑

7.启动JupyterNotebook

jupyter notebook 

8.远程访问

将终端IP地址复制到vscode即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值