亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

Docker Support Tensorflow start

標簽:
Docker

Docker Support Tensorflow start


Tensoflow 容器启动

启动Tensorflow容器还是比较简单的,根据docker hub提供的方法进行容器启动即可

1.搜索镜像
root@es2:~# docker search tensorflowNAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
tensorflow/tensorflow             Official docker images for deep learning f...   1001jupyter/tensorflow-notebook       Jupyter Notebook Scientific Python Stack w...   74xblaster/tensorflow-jupyter       Dockerized Jupyter with tensorflow              50                   [OK]
romilly/rpi-docker-tensorflow     Tensorflow and Jupyter running in docker c...   19floydhub/tensorflow               tensorflow                                      12                   [OK]
bitnami/tensorflow-serving        Bitnami Docker Image for TensorFlow Serving     11                   [OK]
tensorflow/serving                Official images for TensorFlow Serving (ht...   82.下载镜像
root@es2:~# docker pull tensorflow/tensorflowUsing default tag: latestlatest: Pulling from tensorflow/tensorflowb234f539f7a1: Extracting [===========================>                       ]  23.4 MB/43.12 MB55172d420b43: Download complete5ba5bbeb6b91: Download complete43ae2841ad7a: Download completef6c9c6de4190: Download complete5624105f79a2: Downloading [======>                                            ] 17.12 MB/142.4 MB1cbdffd12405: Download complete3.启动容器
docker run -d --name tensorflow_test -p 18888:8888 tensorflow/tensorflow
参数解析:
-d 后台运行
--name 给容器起个名字
-p 映射到本地的端口(本地端口:容器端口)

登录jupyter

1.找到登录token
jupyter登录需要传入token,获取方式如下:

docker ps
root@es2:~# docker psCONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                               NAMES17d804ae12cc        tensorflow/tensorflow    "/run_jupyter.sh -..."   58 seconds ago      Up 58 seconds       6006/tcp, 0.0.0.0:18888->8888/tcp   tensorflow_test
d939ac70635a        google/cadvisor:latest   "/usr/bin/cadvisor..."   5 days ago          Up 5 days           0.0.0.0:8080->8080/tcp              cadvisor
b9f4b7b1295c        registry:2               "/entrypoint.sh /e..."   6 days ago          Up 6 days           0.0.0.0:5000->5000/tcp              registry2

找到要启动容器的ID
docker logs 17d804ae12cc
root@es2:~# docker logs 17d804ae12cc[I 08:13:35.956 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 08:13:35.972 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 08:13:35.980 NotebookApp] Serving notebooks from local directory: /notebooks
[I 08:13:35.980 NotebookApp] 0 active kernels
[I 08:13:35.980 NotebookApp] The Jupyter Notebook is running at:[I 08:13:35.980 NotebookApp] http://17d804ae12cc:8888/?token=4e392a15850c82958dd68a7e2eca205ae112740ce2ceb437
[I 08:13:35.980 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 08:13:35.980 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://17d804ae12cc:8888/?token=4e392a15850c82958dd68a7e2eca205ae112740ce2ceb437&token=4e392a15850c82958dd68a7e2eca205ae112740ce2ceb437

找到这条日志后,然后替换ip与端口http://宿主机:映射端口/?token=4e392a15850c82958dd68a7e2eca205ae112740ce2ceb437

webp

Jupyter.png

容器安装Python3 Anaconda3

如果需要环境中支持Anaconda需要手动去容器安装

1.登录容器
docker exec -it 17d804ae12cc  bash
root@es2:~# docker exec -it 17d804ae12cc  bashroot@17d804ae12cc:/notebooks#2.更新apt-get安装wget
apt-get update
root@17d804ae12cc:/notebooks# apt-get updateGet:1 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]...
apt-get install wget
root@17d804ae12cc:/notebooks# apt-get install wgetReading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
wget
...3.下载Anaconda3
root@17d804ae12cc:/notebooks# wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh--2018-08-07 08:35:17--  https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.shResolving repo.anaconda.com (repo.anaconda.com)... 104.17.111.77, 104.17.110.77, 104.17.107.77, ...
Connecting to repo.anaconda.com (repo.anaconda.com)|104.17.111.77|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 651745206 (622M) [application/x-sh]
Saving to: 'Anaconda3-5.2.0-Linux-x86_64.sh'Anaconda3-5.2.0-Linux-x86_64.sh            15%[===========>
...
Saving to: 'Anaconda3-5.2.0-Linux-x86_64.sh'Anaconda3-5.2.0-Linux-x86_64.sh           100%[==================================================================================>] 621.55M  12.3MB/s    in 49s2018-08-07 08:36:07 (12.6 MB/s) - 'Anaconda3-5.2.0-Linux-x86_64.sh' saved [651745206/651745206]4.运行安装
bash Anaconda3-5.2.0-Linux-x86_64.sh
root@17d804ae12cc:/notebooks# bash Anaconda3-5.2.0-Linux-x86_64.shWelcome to Anaconda3 5.2.0In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue>>>5.jupyter notebook加载pytho3内核
ipython kernel install --name python3
root@17d804ae12cc:/notebooks# ipython kernel install --name python3Installed kernelspec python3 in /usr/local/share/jupyter/kernels/python3

保存镜像

安装了Anaconda3的容器,想在别的机器上使用,而不想再次安装的话,可以将已经安装的容器保存成镜像

1.创建镜像
docker commit  -a "test" -m "install Anaconda3-5.2.0"  17d804ae12cc tensorflow:1.0.0如此就把容器保存成了加载中的镜像,其中TAG为了区分同名镜像的不同版本
语法 docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
说明:
 -a:提交的镜像作者
 -c:使用Dockerfile指令来创建镜像
 -m:提交时的说明文字
 -p:在commit时,将容器暂停

root@es2:~# docker commit  -a "test" -m "install Anaconda3-5.2.0"  17d804ae12cc tensorflow:1.0.0sha256:8ff9c17845442d36f0fe43fbc65fa6cda6aef7a7bd5d69455eaf232b9fc6ceaf

- 查看镜像
root@es2:~# docker imagesREPOSITORY                                 TAG                 IMAGE ID            CREATED             SIZE
tensorflow                                 1.0.0               8ff9c1784544        2 minutes ago       5.22 GBes2:5000/itzzy/eureka-server-1.0.0         latest              3c8d61cfde11        10 days ago         723 MB
itmuch/eureka-server-1.0.0                 latest              3c8d61cfde11        10 days ago         723 MB
itzzy/eureka-server-1.0.0                  latest              3c8d61cfde11        10 days ago         723 MBlocalhost:5000/itzzy/eureka-server-1.0.0   latest              3c8d61cfde11        10 days ago         723 MB
ubuntu                                     16.04               7aa3602ab41e        11 days ago         115 MB
tensorflow/tensorflow                      latest              caab7ec02690        3 weeks ago         1.25 GB2.保存镜像
docker save -o tensorflow_Anaconda3-5.2.0.tar  tensorflow:1.0.0可以看到生成了tar文件
-rw-------  1 root root 5340353536 Aug  7 17:19 tensorflow_Anaconda3-5.2.0.tar3.其他主机加载镜像
只需要把你保存的镜像传过去load 一下就好了
docker load -i tensorflow_Anaconda3-5.2.0.tar



作者:it_zzy
链接:https://www.jianshu.com/p/1cbf058a063d


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消