-
Notifications
You must be signed in to change notification settings - Fork 12
Docker 部署 Python3 Tensorflow Jupyter Notebook sklearn 环境
Tensorflow + Python3 + Jupyter Notebook + sklearn 环境部署。
$ docker pull dash00/tensorflow-python3-jupyter
$ docker run -it -p 8888:8888 dash00/tensorflow-python3-jupyter
If you want to use a persistent folder for notebook, which will not be removed at the end of the container execution, run following command instead:
$ docker run -it -p 8888:8888 -v /$(pwd)/notebooks:/notebooks dash00/tensorflow-python3-jupyter
You can change /$(pwd)/notebooks by any path on the local system. If the folder does not exist, it will be created. This option maps the given local folder with the folder of the notebooks on Jupyter. This folder should contain all your notebooks indeed.
$ docker run --name notebooks -d -v /$(pwd)/notebooks:/notebooks -v /$(pwd)/logs:/logs -p 8888:8888 dash00/tensorflow-python3-jupyter /run_jupyter.sh --allow-root --NotebookApp.token=''
$ docker run --name board -d -v /$(pwd)/logs:/logs -p 6006:6006 dash00/tensorflow-python3-jupyter tensorboard --logdir /logs
Jupyter is available on http://<CONTAINER_IP>:8888/ and Tensorboard will be available on http://<CONTAINER_IP>:6006/
进入 docker image
$ docker run -t -i dash00/tensorflow-python3-jupyter /bin/bash
root@46fef5029c3c:/notebooks#
先看一下是什么系统
root@46fef5029c3c:/notebooks# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
提到装了 python2 和 python3,tf 是装在 python3 下,所以 tflearn 也要装在 python3 下,默认进入的是 python2
# python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
# python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
pip install 要在 python3 下,用以下命令
# python3 -m pip install git+https://github.com/tflearn/tflearn.git
Collecting git+https://github.com/tflearn/tflearn.git
Cloning https://github.com/tflearn/tflearn.git to /tmp/pip-u0c73_t1-build
Error [Errno 2] No such file or directory: 'git' while executing command git clone -q https://github.com/tflearn/tflearn.git /tmp/pip-u0c73_t1-build
Cannot find command 'git'
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
发现没有装 git,就先装一下喽
# apt-get update
# apt-get install git
再次 pip 下
# python3 -m pip install git+https://github.com/tflearn/tflearn.git
# python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tflearn
hdf5 is not supported on this machine (please install/reinstall h5py for optimal experience)
>>>
# python3 -m pip install --upgrade pip
# python3 -m pip install h5py
成功
# python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tflearn
>>>
# exit
$ docker commit -m="install git and tflearn" -a="shuang" b8a10c34f1b0 shuang/tensorflow-tflearn-python3-jupyter:latest
sha256:97748739b45dc8ce994521fa11d7ad6349bc83762e76139086789e0416560710
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
shuang/tensorflow-tflearn-python3-jupyter latest ce94a8fa0e16 20 hours ago 1.24 GB
dash00/tensorflow-python3-jupyter latest 34eeac184315 4 weeks ago 1.17 GB
hello-world latest 48b5124b2768 5 months ago 1.84 kB
$ docker run -it -p 8888:8888 -v /$(pwd)/notebooks:/notebooks shuang/tensorflow-tflearn-python3-jupyter
在完成操作之后,输入 exit命令来退出这个容器。 此时ID为e218edb10161的容器,是按我们的需求更改的容器。我们可以通过命令 docker commit来提交容器副本。 $ docker commit -m="install git and tflearn" -a="shuang" 46fef5029c3c shuang/tensorflow-tflearn-python3-jupyter:latest
sha256:70bf1840fd7c0d2d8ef0a42a817eb29f854c1af8f7c59fc03ac7bdee9545aff8 各个参数说明: -m:提交的描述信息 -a:指定镜像作者 46fef5029c3c:容器ID shuang/ubuntu:v2:指定要创建的目标镜像名 我们可以使用 docker images 命令来查看我们的新镜像 runoob/ubuntu:v2:
[[TOC]]