一、Docker安装

安装

进入Install Docker Engine,然后选择对应的平台根据官网教程走即可

Install_Docker_Engine_platform.png

配置镜像源

修改/etc/docker/daemon.json该文件内容为:

{
    "registry-mirrors": [
        "https://dockerproxy.com",
        "https://hub-mirror.c.163.com",
        "https://mirror.baidubce.com",
        "https://ccr.ccs.tencentyun.com"
    ]
}

然后执行命令

systemctl daemon-reload && systemctl restart docker
docker info

出现以下内容即为成功

docker_info_mirror.png

二、Jupyter Notebook安装

创建安装目录

mkdir /mnt/jupyter-notebook # 目录按需修改
cd /mnt/jupyter-notebook
mkdir notebooks
chmod 777 ./notebooks

创建docker-compose.yml

可选镜像源参考:Docker Stacks documentation

version: '3'
services:
  jupyter:
    # 按需修改镜像源
    image: jupyter/tensorflow-notebook:latest
    # 按需修改资源限制
    deploy:
        resources:
            limits:
              cpus: '0.60'
              memory: 2G
            reservations:
              cpus: '0.2'
              memory: 256M
    ports:
      - "8888:8888"
    # 按需配置路径挂载
    volumes:
      - ./notebooks:/home/jovyan/work

安装Jupyter Notebook

docker-compose up -d # 执行时间长短取决与网速和机器配置

浏览器输入网址访问(其中yourip根据实际IP替换):http://yourip:8888

出现以下界面表示安装成功

jupter_notebook_install_success.png

登录Jupyter Notebook

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                                 ...
88f492a4253d   jupyter/datascience-notebook:latest   ...
[root@localhost ~]# docker exec -it 88f492a4253d /bin/bash # 88f492a4253d为上面的容器id
jovyan@88f492a4253d:~$ jupyter server list
Currently running servers:
http://88f492a4253d:8888/?token=308qgaerbbezvc4tzh6mzrr96f2k343jt8ksy6jqt213ysw4 :: /home/jovyan

浏览器输入网址访问(其中yourip和token根据实际IP和token替换):

http://yourip:8888/?token=308qgaerbbezvc4tzh6mzrr96f2k343jt8ksy6jqt213ysw4

出现以下界面表示登录成功

jupter_notebook_login_success.png

安装中文包(可选)

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                                 ...
88f492a4253d   jupyter/datascience-notebook:latest   ...
[root@localhost ~]# docker exec -it 88f492a4253d /bin/bash # 88f492a4253d为上面的容器id
jovyan@88f492a4253d:~$ pip install jupyterlab-language-pack-zh-CN

jupter_notebook_use_chinese_package.png

jupter_notebook_use_chinese_package_1.png

安装Streamlit

Streamlit是一个开源Python库,可以轻松创建和共享用于机器学习和数据科学的漂亮的自定义web应用程序。

jovyan@88f492a4253d:~$ pip install streamlit
......
jovyan@88f492a4253d:~$ streamlit hello

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.


  Welcome to Streamlit. Check out our demo in your browser.

  Network URL: http://127.0.0.1:8501
  External URL: http://127.0.0.1:8501

  Ready to create your own Python apps super quickly?
  Head over to https://docs.streamlit.io

  May you create awesome apps!

浏览器输入网址访问(其中yourip根据实际IP替换):

http://yourip:8501/

出现以下界面表示安装成功

4e28afc0-7269-c8c6-0e04-052faaf31030.png

安装PyTorch

jovyan@0d47b4091956:~/work$ pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple
......
jovyan@0d47b4091956:~/work$ pip install torchvision -i https://pypi.tuna.tsinghua.edu.cn/simple
......

安装其他软件

jovyan@0d47b4091956:~/work$ conda install torchvision
jovyan@0d47b4091956:~/work$ pip install mxnet
jovyan@0d47b4091956:~/work$ pip install rise
jovyan@0d47b4091956:~/work$ pip install -U d2l

三、Jupyter Notebook设置

终端字体设置

设置>设置编辑器>终端>字体集 => Consolas