保护私人版权,尊重他人版权。转载请注明出处并附带页面链接
一、在阿里云后台选择合适的配置
话不多说,先上图,可以按照图片选择自己对应的机器,其中需要注意的是按照当前(20201212)TensorFlow 2.3
的版本对应我们需要选择的cuda版本为 10.2 ,而 cudnn版本则需要选择 7.6.5版本。~~我第一次装选错了然后需要自己手动修改so文件,可以跑起来但是后面会各种奇怪的报错。所以请选择正确版本一步到位。

二、下载并安装minicoda
Anaconda是一个开源的Python发行版本,包含了conda、python等180多个科学包及其依赖项。所以我们安装 miniconda 主要是为了省点空间和时间, Conda 是一个开源的软件包管理系统和环境管理系统,用于安装多个版本的软件包及其依赖关系,并在它们之间轻松切换。
我们可以通过这个链接
https://docs.conda.io/en/latest/miniconda.html
找到自己需要的系统安装包。linux的安装包我用这个,建议官网下载 。PS:建议不要在root用户下执行下载和安装操作。1
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
下载完成后我们可以修改下载的.sh的文件的可执行权限
chmod +x 文件文件名
然后执行
./Miniconda3-latest-Linux-x86_64.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22第一步确认是否安装。。。直接回车
第二步阅读协议没问题后。。。回车
第三步确认目录 如下。。。然后回车
[/root/miniconda3] >>>
PREFIX=/root/miniconda3
第四步看到如下
Preparing transaction: done
Executing transaction: done
installation finished.
Do you wish the installer to initialize Miniconda3
by running conda init? [yes|no]
输入yes 回车
输出如下结果就是完成安装
==> For changes to take effect, close and re-open your current shell. <==
If you'd prefer that conda's base environment not be activated on startup,
set the auto_activate_base parameter to false:
conda config --set auto_activate_base false
Thank you for installing Miniconda3!需要设置 ~/.bashrc
1
2
3
4
5vim ~/.bashrc
在最后一行输入
export PATH="/用户名/miniconda3/bin:$PATH"
然后保存之后就可以了如果是在阿里云选择了自动安装 cuda和cudnn的话则需要查看root用户/你第一个创建用户(可能不叫root?)的
/.bashrc 文件中类似下面这两行的东东,将它复制到 第四步中(如果这个也是root用户那就不用加这个了) 编辑的/.bashrc 并执行source ~/.bashrc
。1
2export PATH=/usr/local/bin:/usr/local/cuda-10.1/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH
三、配置可以使用jupyter远程访问调试学习
因为安装的 miniconda ,所以这时候还需要安装 jupyter notebook (如果不需要用网页访问的话只需要做到上面就行了)。
1
2
3
4
5
6
7
8
9
10
11
12
13pip install --ignore-installed --upgrade jupyter -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com #这里使用阿里云的源,比较快
#然后提前安装好我使用tensorflow时需要的包
#安装tensorflow
pip install --ignore-installed --upgrade tensorflow -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
#-------下面的包自己按需安装,可以不用管
pip install --ignore-installed --upgrade tensorflow -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install --ignore-installed --upgrade bs4 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install --ignore-installed --upgrade pandas -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install --ignore-installed --upgrade sklearn -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install --ignore-installed --upgrade matplotlib -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install --ignore-installed --upgrade jieba -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install --ignore-installed --upgrade lxml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install --ignore-installed --upgrade seaborn -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com配置nginx,因为需要安装nginx
1
yum install nginx
配置nginx,具体为什么要这么配置请看(http://nginx.org/en/docs/http/websocket.html)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20cd /etc/nginx/conf.d/
#新建配置文件
vi jupyter.conf
#内容如下
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 端口;
server_name 你的机器公网IP;
location / {
proxy_pass http://127.0.0.1:8888;#启动的jupyter服务地址ip:端口
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}启动nginx
1
输入并执行 nginx 就可以启动了
jupyter 配置
1
2
3
4
5#编辑 /home/user_00/.jupyter/jupyter_notebook_config.py
#开放支持跨域--修改并去掉注释为
c.NotebookApp.allow_origin = '*'
#需要开放远程访问---去掉注释
c.NotebookApp.allow_remote_access = True然后去你的工作目录(自己定。随便)
1
2
3
4
5执行 jupyter notebook
启动成功后
可以看到对应的带token的地址,只需要吧内网ip换为公网ip和你配置的端口就可以了。
输入
http://ip:端口/?token=xxxxxxx 就可以访问了。愉快操作。