【转】docker 搭建TensorFlow环境

1,关于TensorFlow


TensorFlow 随着AlphaGo的胜利也火了起来。 
google又一次成为大家膜拜的大神了。google大神在引导这机器学习的方向。 
同时docker 也是一个非常好的工具,大大的方便了开发环境的构建,之前需要配置安装。 
看各种文档,现在只要一个 pull 一个 run 就可以把环境弄好了。 
同时如果有写地方需要个性化定制,直接在docker的镜像上面再加一层补丁就好了。 
自己的需求就能满足了,同时还可以将这个通用的方法分享出去。

2,下载TensorFlow images


使用hub.docker.com的镜像

docker pull tensorflow/tensorflow:latest
  • 1

使用daocloud 的镜像,在国内用速度还是挺快的,如果docker.io的镜像慢,可以用daocloud的。 
这个速度非常的快。一样用的。版本也挺新的。

docker pull daocloud.io/daocloud/tensorflow:latest 
  • 1

3,启动镜像


启动命令,设置端口,同时配置volume 数据卷,用于永久保存数据。加上 –rm 在停止的时候删除镜像。

sudo mkdir -p /data/tensorflow/notebooks
docker run -it --rm --name myts -v /data/tensorflow/notebooks:/notebooks -p 8888:8888 daocloud.io/daocloud/tensorflow:latest
  • 1
  • 2

启动的时候并不是daemon 模式的,而是前台模式,同时显示了运行的日志。

W 06:48:13.425 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 06:48:13.432 NotebookApp] Serving notebooks from local directory: /notebooks
[I 06:48:13.432 NotebookApp] 0 active kernels 
[I 06:48:13.432 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/?token=2031705799dc7a5d58bc51b1f406d8771f0fdf3086b95642
[I 06:48:13.433 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 06:48:13.433 NotebookApp] 

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=2031705799dc7a5d58bc51b1f406d8771f0fdf3086b95642
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

打开浏览器就可以直接看到界面了。 

同时可以编辑内容: 

写第一个 hello world: 

import tensorflow as tf
a = tf.constant(10)
b = tf.constant(32)

with tf.Session():
    c = tf.add(a,b)
    print(c)
    print(c.eval())
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

其他的使用参考中文手册: 
https://github.com/jikexueyuanwiki/tensorflow-zh 
里面有pdf 可以下载使用。

还有一个超级炫酷吊炸天的playground : 
http://playground.tensorflow.org/ 

原来博文:https://blog.csdn.net/freewebsys/article/details/70237003

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值