基于docker的TensorFlow开发环境搭建

来源:互联网 发布:剑灵帅气灵男捏脸数据 编辑:程序博客网 时间:2024/04/28 17:32

1 Ubuntu平台

对于ubuntu12.04的安装需要增加ubuntu的下载源

1.1 编辑下载源:在/etc/apt/sources.list文件中增加以下命令行

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

1.2 新下载源

sudo apt-get update

1.3 问题处理

  1. FATA[0000] Get http:///var/run/docker.sock/v1.17/version: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
  2. 其他FATA[0000] 问题
    解决方案:sudo apt-get install apparmor

2 Windows平台

windows直接安装dockertoolbox即可
https://www.docker.com/products/docker-toolbox
推荐版本为ubuntu 14.04,内核版本不低于

3 TensorFlow镜像下载运行

sudo docker pull tensorflow/tensorflow
bash方式:sudo docker run -it tensorflow/tensorflow bash
web方式:docker run -it -p 8888:8888 tensorflow/tensorflow
通过http://IP地址:8888进行访问

4 TensorFlow程序

镜像中没有vi或者vim编辑工具,直接使用Python脚本交互式运行一下脚本得到输出结果,中间存在警告,目前已经忽略。

#Pythonimport tensorflow as tfhello = tf.constant("Hello, TensorFlow!");sess = tf.Session();print(sess.run(hello));

中间的警告如下:

2017-08-21 10:45:47.379464: W tensorflow/core/platform/cpu_feature_guard.cc:45]The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.2017-08-21 10:45:47.379519: W tensorflow/core/platform/cpu_feature_guard.cc:45]The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.2017-08-21 10:45:47.379536: W tensorflow/core/platform/cpu_feature_guard.cc:45]The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.

输出结果如下:

hello, TensorFlow!

4 参考链接

[1] https://www.w3cschool.cn/docker/ubuntu-docker-install.html

原创粉丝点击