docker安装 Tensorflow遇到问题i/o timeout.

docker: Error response from daemon: Get https://gcr.io/v1/_ping: dial tcp 64.233.188.82:443: i/o timeout.

Tensorflow 是Google的一个开源机器学习框架,中国大陆的用户在使用的时候往往需要爬过GFW墙,借助VPN。

依照Tensorflow的官方文档 在docker中安装Tensorflow的时候,国内的用户通常会报错,有的借助VPN可以解决,而有的不行。

(1)在docker成功安装完后,在终端命令行输入:

sudo docker run -it -p 8888:8888 gcr.io/tensorflow/tensorflow

(2)报错如下:

Unable to find image 'gcr.io/tensorflow/tensorflow:latest' locally
docker: Error response from daemon: Get https://gcr.io/v1/_ping: dial tcp 64.233.188.82:443: i/o timeout.
See 'docker run --help'.

主要原因还是因为GFW,在Github上有人提出过引起这个问题的原因,tensorflow/issues/1273,点击此链接

(3)关于这个,问题,我觉得最简单的办法是更换镜像的pull镜像库。也就是说,不是从Tensorflow给出的库(Google Cloud Platform)进行pull,而是用docker的库(docker hub)。

docker hub 中的tensorflow镜像介绍:

因此,在终端输入如下命令:

sudo docker run -it -p 8888:8888 tensorflow/tensorflow

只要你的docker是安装成功,能够pull镜像,那么基本会成功安装Tensorflow。我的运行输出如下:

Unable to find image 'tensorflow/tensorflow:latest' locally
latest: Pulling from tensorflow/tensorflow
862a3e9af0ae: Pull complete
6498e51874bf: Pull complete
159ebdd1959b: Pull complete
0fdbedd3771a: Pull complete
7a1f7116d1e3: Pull complete
f22ce26e7804: Pull complete
80e54362977d: Pull complete
6bf17916f3f1: Pull complete
cbb2cc9179cb: Pull complete
4f976cd18afd: Pull complete
31ba02bae790: Pull complete
e26c94fb0976: Pull complete
Digest: sha256:feedf027da0d525300dc73e433b4ade2147c6a408756cdd9846fd37b40929f8a
Status: Downloaded newer image for tensorflow/tensorflow:latest
[I 03:19:59.901 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 03:19:59.981 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 03:20:00.015 NotebookApp] Serving notebooks from local directory: /notebooks
[I 03:20:00.015 NotebookApp] 0 active kernels
[I 03:20:00.015 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/?token=93a4eec743c0601c77e6b3f88386da5efab335f49d6a476e
[I 03:20:00.015 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 03:20:00.016 NotebookApp] Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=93a4eec743c0601c77e6b3f88386da5efab335f49d6a476e
[I 03:25:55.708 NotebookApp] 302 GET /?token=93a4eec743c0601c77e6b3f88386da5efab335f49d6a476e (172.17.0.1) 0.45ms

因为这个镜像比较大,所以会需要一定的时间pull,耐心等待就好。

(4)打开一个新的命令终端进行测试是否安装成功:

首先,查看docker中有哪些容器/镜像存在

sudo docker ps -a

得到如下格式的输出:

注意到,第一个容器即是我们安装的tensorflow的镜像在运行的容器,其ID是53f212117a94

接着,进入容器:
替换我的这个53f212117a94 为你的,其他命令不变

sudo docker exec -i -t 53f212117a94 /bin/bash
  • 1

得到输入如下:

mingchen@mingchen-HP:~$ sudo docker exec -i -t 53f212117a94 /bin/bash
root@53f212117a94:/notebooks#

看看python版本:

root@53f212117a94:/notebooks# python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.

输出Hello, TensorFlow!:

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!

简单计算:

>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42

测试结果显示,已成功在docker中安装Tensorflow。

docker安装tensorflow环境遇到的问题与解决方案的更多相关文章

  1. Ubuntu 基于Docker的TensorFlow 环境搭建

    基于Docker的TensorFlow 环境搭建 基于(ubuntu 16.04LTS/ubuntu 14.04LTS) 一.docker环境安装 1)更新.安装依赖包 sudo apt-get up ...

  2. Docker安装 - CentOS7环境

    Docker安装 - CentOS7环境 安装Docker 我是虚拟机装的Centos7,linux 3.10 内核,docker官方说至少3.8以上,建议3.10以上(ubuntu下要linux内核 ...

  3. Ubuntu中的Docker搭建Tensorflow环境

    一.docker环境安装 1)更新.安装依赖包 sudo apt-get update sudo apt-get install apt-transport-https ca-certificates ...

  4. windows下使用docker安装tensorflow

    一.安装Docker 1.首先先按照docker,从https://get.daocloud.io/toolbox/  下载exe文件就好 双击安装会多出来三个东西: Oracle VM Virtua ...

  5. docker安装+测试环境的搭建---

    漏洞演练环境docker地址:http://vulhub.org/#/environments/ 环境:kali-linux-2017.2-amd64.iso 一.docker安装 1.先更新一波源: ...

  6. Docker 安装tensorflow

    安装DOCKER 1. https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/ nstall from a packag ...

  7. docker安装与环境部署

    使用docker搭建环境 摘要 install docker start docker install docker-compose 部署upload-labs/sqli-labs 部署dvwa 部署 ...

  8. docker安装Tensorflow并使用jupyter notebook

    目前网上提供的大多数的方法都是如下: docker pull tensorflow/tensorflow docker run -it -p : tensorflow/tensorflow 但是按照步 ...

  9. Docker安装开发环境

    目录 Docker Docker 安装 Mysql Docker 安装Redis Docker 安装Zookeeper Docker Docker 安装 Mysql Docker 查看可用Mysql镜 ...

随机推荐

  1. Data Binding Guide——google官方文档翻译(下)

    这篇博客是Data Binding Guide官网文档翻译的下篇.假设没看过前半部分翻译的能够先看Data Binding Guide--google官方文档翻译(上)  一,数据对象 不论什么不含业 ...

  2. [Angular] Performance Caching Policy - Cache First, Network Last

    If you want to cache API response by using angular service-worker, you can do it in: src/ngsw-config ...

  3. Oracle 11gR2 List-Range分区实验

    一.实验目的 採用List-Range分区,对主分区指定表空间或者对子分区指定表空的不同情况,測试例如以下内容: 1.对List主分区不指定表空间.对Range子分区指定表空间,数据实际存储在哪个表空 ...

  4. poj--2236--棋盘问题(dfs)

    棋盘问题 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 31183   Accepted: 15469 Descriptio ...

  5. 【POJ 3090】 Visible Lattice Points

    [题目链接] http://poj.org/problem?id=3090 [算法] 通过观察发现,在这个平面直角坐标系中,除了(1,1),(1,0)和(0,1),所有可见点的横纵坐标互质 那么,问题 ...

  6. 用WPF做关于MEF 简单学习记录

    写在前面:下面学习所得多是从自http://www.cnblogs.com/comsokey/p/MEF1.html和http://www.cnblogs.com/yunfeifei/p/392266 ...

  7. linux编译安装gdb7.10.1

    1.下载GDB7.10.1安装包 #wget http://ftp.gnu.org/gnu/gdb/gdb-7.10.1.tar.gz 2.解压 #.tar.gz 3.创建安装目录 #/ #cd /u ...

  8. QlikSense系列(4)——QlikSense管理

    QlikSense管理主要通过QMC界面,在安装成功后,首先需要导入用户,QlikSense本身不能创建和验证用户,只能借助第三方系统, 笔者只使用过Windows账户和AD域用户: 1.Window ...

  9. P3808 【模版】AC自动机(简单版)

    题目背景 这是一道简单的AC自动机模版题. 用于检测正确性以及算法常数. 为了防止卡OJ,在保证正确的基础上只有两组数据,请不要恶意提交. 题目描述 给定n个模式串和1个文本串,求有多少个模式串在文本 ...

  10. Linux od与hexdump命令

    od命令:以指定格式输出文件内容常用格式:od -Ax -tx1 filename直接格式:od filename 等价 od -o filename语法:od [-abcdfsiloxv] [-An ...