基于docker的TensorFlow开发环境搭建

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脚本交互式运行一下脚本得到输出结果,中间存在警告,目前已经忽略。

#Python
import tensorflow as tf
hello = 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 av
ailable on your machine and could speed up CPU computations.

输出结果如下:

hello, TensorFlow!

4 参考链接

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值