使用国内镜像库安装TensorFlow

来源:互联网 发布:大数据新手视频 编辑:程序博客网 时间:2024/04/18 08:29

国内镜像库推荐:
网易:https://c.163.com/hub#/m/library/
阿里云:https://dev.aliyun.com/
本文使用阿里云镜像库


先安装好docker
Pull images拉取镜像

$ sudo docker pull ubuntu # 获取 ubuntu 官方镜像 $ sudo$ sudo docker pull registry.cn-hangzhou.aliyuncs.com/denverdino/tensorflow

查看当前镜像列表:

$ sudo docker images

进入bash

sudo docker run  -i -t registry.cn-hangzhou.aliyuncs.com/denverdino/tensorflow /bin/bash

查看容器

$ sudo docker ps # 查看当前运行的容器, ps -a 列出当前系统所有的容器

进入正在运行中的容器

sudo docker exec -it 6665676662b1 /bin/bash

运行 TensorFlow :
在Docker容器中打开一个 python 终端

$ python>>> 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 run -it --name linux123 ubuntu /bin/bash
3 0