安装docker的过程和docker的基本操作, 参见容器00-使用docker安装运行httpd.
安装tensorflow的docker映像
查找tensorflow映像
root@iZ28oqjyulkf54Z:~# docker search tensorflow
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
tensorflow/tensorflow Official docker images for deep learning f... 952
jupyter/tensorflow-notebook Jupyter Notebook Scientific Python Stack w... 74
xblaster/tensorflow-jupyter Dockerized Jupyter with tensorflow 50 [OK]
romilly/rpi-docker-tensorflow Tensorflow and Jupyter running in docker c... 19
bitnami/tensorflow-serving Bitnami Docker Image for TensorFlow Serving 11 [OK]
floydhub/tensorflow tensorflow 10 [OK]
tensorflow/tf_grpc_server Server for TensorFlow GRPC Distributed Run... 6
opensciencegrid/tensorflow-gpu TensorFlow GPU set up for OSG 4
tensorflow/tf_grpc_test_server Testing server for GRPC-based distributed ... 3
eboraas/tensorflow TensorFlow with Jupyter Notebook, includin... 2 [OK]
hytssk/tensorflow tensorflow image with matplotlib.pyplot.im... 2 [OK]
mikebirdgeneau/r-tensorflow RStudio and Tensorflow 1 [OK]
chaneyk/tensorflow Tensorflow Releases with GPU Support 1
abhishek404/tensorflow-gpu Tensorflow GPU image 1
bitnami/tensorflow-inception Bitnami Docker Image for TensorFlow Inception 1 [OK]
opensciencegrid/tensorflow TensorFlow image with some OSG additions 0
spellrun/tensorflow 0
djpetti/rpinets-tensorflow Tensorflow container that is ready to be u... 0 [OK]
spellrun/tensorflow-cpu-jupyter 0
andreleoni/cnn-tensorflow Container for convlutional network with P... 0
spellrun/tensorflow-cpu 0
mediadesignpractices/tensorflow Tensorflow w/ CUDA (GPU) + extras 0 [OK]
davidchiu/tensorflow09 tensorflow09 with GPU support 0
aretelabs/tensorflow 0
fluxcapacitor/prediction-tensorflow 0
[1]+ Done nohup docker pull continuumio/anaconda3
安装tensorflow映像
root@iZ28oqjyulkf54Z:~# docker pull tensorflow/tensorflow
Using default tag: latest
latest: Pulling from tensorflow/tensorflow
b234f539f7a1: Pull complete
55172d420b43: Pull complete
5ba5bbeb6b91: Pull complete
43ae2841ad7a: Pull complete
f6c9c6de4190: Pull complete
5624105f79a2: Pull complete
1cbdffd12405: Pull complete
4111af644df8: Pull complete
060d55811dc3: Pull complete
41163fa89121: Pull complete
33ccfe03d160: Pull complete
eb5cd31a3268: Pull complete
b5fae668ebb8: Pull complete
Digest: sha256:92ad7f5da1f0e7c2c7b714b77b12424ae3d7971510d8ff8673b8b0695c3fd1c9
Status: Downloaded newer image for tensorflow/tensorflow:latest
运行tensorflow的docker映像成为容器
-p 本机的8888端口映射到docker的8888端口.
根据docker运行的提示, 在浏览器中输入url:
http://本主机的IP地址:8888/?token=bbedb9686417ddaf0fb4202a1772ec336434e918f09b227a&token=bbedb9686417ddaf0fb4202a1772ec336434e918f09b227a
注意需要把主机的名称换为本主机的IP地址.
root@iZ28oqjyulkf54Z:~# docker run -it -p 8888:8888 tensorflow/tensorflow
[I 06:32:28.396 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 06:32:28.413 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 06:32:28.421 NotebookApp] Serving notebooks from local directory: /notebooks
[I 06:32:28.421 NotebookApp] 0 active kernels
[I 06:32:28.421 NotebookApp] The Jupyter Notebook is running at:
[I 06:32:28.421 NotebookApp] http://74cfcce53529:8888/?token=bbedb9686417ddaf0fb4202a1772ec336434e918f09b227a
[I 06:32:28.421 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 06:32:28.422 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://74cfcce53529:8888/?token=bbedb9686417ddaf0fb4202a1772ec336434e918f09b227a&token=bbedb9686417ddaf0fb4202a1772ec336434e918f09b227a
[I 06:33:06.248 NotebookApp] 302 GET / (175.171.173.103) 0.70ms
[I 06:33:06.281 NotebookApp] 302 GET /tree? (175.171.173.103) 0.55ms
[W 06:33:46.840 NotebookApp] 401 POST /login?next=%2Ftree%3F (175.171.173.103) 1.62ms referer=http://microais.cn:8888/login?next=%2Ftree%3F
[I 06:34:28.471 NotebookApp] 302 GET /?token=bbedb9686417ddaf0fb4202a1772ec336434e918f09b227a&token=bbedb9686417ddaf0fb4202a1772ec336434e918f09b227 (175.171.173.103) 0.61ms
[I 06:34:28.508 NotebookApp] 302 GET /tree?token=bbedb9686417ddaf0fb4202a1772ec336434e918f09b227a&token=bbedb9686417ddaf0fb4202a1772ec336434e918f09b227 (175.171.173.103) 1.02ms
[I 06:35:31.600 NotebookApp] 302 GET /?token=bbedb9686417ddaf0fb4202a1772ec336434e918f09b227a&token=bbedb9686417ddaf0fb4202a1772ec336434e918f09b227a (175.171.173.103) 0.53ms
[I 06:36:32.911 NotebookApp] Writing notebook-signing key to /root/.local/share/jupyter/notebook_secret
[W 06:36:32.912 NotebookApp] Notebook 1_hello_tensorflow.ipynb is not trusted
[I 06:36:33.874 NotebookApp] Kernel started: ae0eb500-0c8d-49cf-8e48-91dbf5cd7a95
[I 06:36:34.227 NotebookApp] Adapting to protocol v5.1 for kernel ae0eb500-0c8d-49cf-8e48-91dbf5cd7a95
[I 06:37:23.439 NotebookApp] Kernel shutdown: ae0eb500-0c8d-49cf-8e48-91dbf5cd7a95
[W 06:37:34.793 NotebookApp] Notebook 2_getting_started.ipynb is not trusted
[I 06:37:35.634 NotebookApp] Kernel started: 4500cddd-4614-447f-a1cf-82b84ef2374c
[I 06:37:35.990 NotebookApp] Adapting to protocol v5.1 for kernel 4500cddd-4614-447f-a1cf-82b84ef2374c
[I 06:38:33.905 NotebookApp] Saving file at /1_hello_tensorflow.ipynb
浏览器显示内容
附录: 直接用anaconda安装TensorFlow
不使用docker. 由于清华的源比较近, 安装速度似乎更快.
安装anaconda
Anaconda 安装包可以到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载.
在ubuntu18.04安装anaconda
$chmod +x Anaconda3-5.2.0-Linux-x86_64.sh
$./Anaconda3-5.2.0-Linux-x86_64.sh
在安装的最后, 安装Visual Studio Code需要当前用户的sudo口令.
更换软件源
$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 --set show_channel_urls yes
安装tensorflow
$conda search tensorflow
$conda install tensorflow
安装opencv
$conda search opencv
$conda install opencv
安装keras
$conda search keras
$conda install keras