TensorFlow Docker requirements

  1. Install Docker on your local host machine.
  2. For GPU support on Linux, install nvidia-docker.

Note: To run the docker command without sudo, create the docker group and add your user. For details, see the post-installation steps for Linux.

Download a TensorFlow Docker image

The official TensorFlow Docker images are located in the tensorflow/tensorflow Docker Hub repository. Image releases are tagged using the following format:

Tag Description
latest The latest release of TensorFlow CPU binary image. Default.
nightly Nightly builds of the TensorFlow image. (unstable)
version Specify the version of the TensorFlow binary image, for example: 1.14.0
devel Nightly builds of a TensorFlow master development environment. Includes TensorFlow source code.

Each base tag has variants that add or change functionality:

Tag Variants Description
tag-gpu The specified tag release with GPU support. (See below)
tag-py3 The specified tag release with Python 3 support.
tag-jupyter The specified tag release with Jupyter (includes TensorFlow tutorial notebooks)

You can use multiple variants at once. For example, the following downloads TensorFlow release images to your machine:

docker pull tensorflow/tensorflow                     # latest stable release
docker pull tensorflow/tensorflow:devel-gpu           # nightly dev release w/ GPU support
docker pull tensorflow/tensorflow:latest-gpu-jupyter  # latest release w/ GPU support and Jupyter
 

Start a TensorFlow Docker container

To start a TensorFlow-configured container, use the following command form:

docker run [-it] [--rm] [-p hostPort:containerPort] tensorflow/tensorflow[:tag] [command]
 

For details, see the docker run reference.

Examples using CPU-only images

Let's verify the TensorFlow installation using the latest tagged image. Docker downloads a new TensorFlow image the first time it is run:

docker run -it --rm tensorflow/tensorflow \
   python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
 

Success: TensorFlow is now installed. Read the tutorials to get started.

Let's demonstrate some more TensorFlow Docker recipes. Start a bash shell session within a TensorFlow-configured container:

docker run -it tensorflow/tensorflow bash
 

Within the container, you can start a python session and import TensorFlow.

To run a TensorFlow program developed on the host machine within a container, mount the host directory and change the container's working directory (-v hostDir:containerDir -w workDir):

docker run -it --rm -v $PWD:/tmp -w /tmp tensorflow/tensorflow python ./script.py
 

Permission issues can arise when files created within a container are exposed to the host. It's usually best to edit files on the host system.

Start a Jupyter Notebook server using TensorFlow's nightly build with Python 3 support:

docker run -it -p 8888:8888 tensorflow/tensorflow:nightly-py3-jupyter
 

Follow the instructions and open the URL in your host web browser: http://127.0.0.1:8888/?token=...

GPU support

Docker is the easiest way to run TensorFlow on a GPU since the host machine only requires the NVIDIA® driver (the NVIDIA® CUDA® Toolkit is not required).

Install nvidia-docker to launch a Docker container with NVIDIA® GPU support. nvidia-docker is only available for Linux, see their platform support FAQ for details.

Check if a GPU is available:

lspci | grep -i nvidia
 

Verify your nvidia-docker installation:

docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
 

Note: nvidia-docker v1 uses the nvidia-docker alias, where v2 uses docker --runtime=nvidia.

Examples using GPU-enabled images

Download and run a GPU-enabled TensorFlow image (may take a few minutes):

docker run --runtime=nvidia -it --rm tensorflow/tensorflow:latest-gpu \
   python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
 

It can take a while to set up the GPU-enabled image. If repeatably running GPU-based scripts, you can use docker execto reuse a container.

Use the latest TensorFlow GPU image to start a bash shell session in the container:

docker run --runtime=nvidia -it tensorflow/tensorflow:latest-gpu bash
 

NVIDIA-docker Cheatsheet的更多相关文章

  1. CentOS7 Nvidia Docker环境

    最近在搞tensorflow的一些东西,话说这东西是真的皮,搞不懂.但是环境还是磕磕碰碰的搭起来了 其实本来是没想到用docker的,但是就一台配置较好电的服务器,还要运行公司的其他环境,vmware ...

  2. ubuntu18.04配置nvidia docker和远程连接ssh+远程桌面连接(一)

    ubuntu18.04配置nvidia docker和远程连接ssh+远程桌面连接(一) 本教程适用于想要在远程服务器上配置docker图形界面用于深度学习的用户. (一)ubuntu18.04配置n ...

  3. ubuntu18.04配置nvidia docker和远程连接ssh+远程桌面连接(三)

    ubuntu18.04配置nvidia docker和远程连接ssh+远程桌面连接(三) 本教程适用于想要在远程服务器上配置docker图形界面用于深度学习的用户. (三)配置远程桌面连接访问dock ...

  4. ubuntu18.04配置nvidia docker和远程连接ssh+远程桌面连接(二)

    ubuntu18.04配置nvidia docker和远程连接ssh+远程桌面连接(二) 本教程适用于想要在远程服务器上配置docker图形界面用于深度学习的用户. (二)nvidia docker配 ...

  5. centos7 安装 NVIDIA Docker

    安装环境: 1.centos7.3 2.NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] 安装nvidia-docker a.安装docker 可参考ce ...

  6. Docker Cheatsheet

    一.创建 docker create:创建容器,处于停止状态. centos:latest:centos容器:最新版本(也可以指定具体的版本号).本地有就使用本地镜像,没有则从远程镜像库拉取.创建成功 ...

  7. docker 系列 - Docker CheatSheet | Docker 配置与实践清单 (转载)

    本文转载自 (https://segmentfault.com/a/1190000016447161), 感谢作者.

  8. Ubuntu16.04下nvidia驱动+nvidia-docker+cuda9+cudnn7安装

    一.宿主机安装nvidia驱动 打开终端,先删除旧的驱动: sudo apt-get purge nvidia* 禁用自带的 nouveau nvidia驱动 sudo gedit /etc/modp ...

  9. 基于Docker容器使用NVIDIA-GPU训练神经网络

    一,nvidia K80驱动安装 1,  查看服务器上的Nvidia(英伟达)显卡信息,命令lspci |grep NVIDIA 05:00.0 3D controller: NVIDIA Corpo ...

  10. kubectl kubernetes cheatsheet

    from : https://cheatsheet.dennyzhang.com/cheatsheet-kubernetes-a4 PDF Link: cheatsheet-kubernetes-A4 ...

随机推荐

  1. 十、lambda表达式、内置函数之filter、map、reduce

    lambda表达式   学习条件运算时,对于简单的 if else 语句,可以使用三元运算来表示,即: # 普通条件语句 == : name = 'wupeiqi' else: name = 'ale ...

  2. pandas 生成并排放置的条形图和箱线图

    1.代码 import numpy as np import pandas as pd import matplotlib.pyplot as plt # 生成数据,创建 DataFrame np.r ...

  3. 通过async实现协程的延迟执行及结果获取

    在上一次https://www.cnblogs.com/webor2006/p/12022065.html对于协程的async和wait进行了初步的学习,其可以加速执行的性能,其实对于async它是提 ...

  4. mysql在windows下安装(含客户端工具)

    下载 http://dev.mysql.com/downloads/ 安装 在出现选择安装类型的窗口中,有“typical(默认)”.“Complete(完全)”.“Custom(用户自定义)”三个选 ...

  5. Java XML文档

    概念 XML(EXtensible Markup Language),可扩展标记语言.可扩展就是<>内的东西可以自己定义,可以随便写.标记语言就是加了<>符号的 .HTML是超 ...

  6. Anaconda3(5-1)程序编辑器 自带的spyder

    1装好后自带spyder编辑器 2 打开软件 3 每次程序需要制定anaconda3中创建的虚拟环境对应 的python版本的路径 例如在我的电脑我创建了两个环境 而我的pytorch安装在pytho ...

  7. 创建、查看、删除计划任务at命令举例

    1.三天后的下午 5 点执行 /bin/ls : at 5pm + 3 days at> /bin/ls             结束按ctrl+d 查看计划任务:at -l 之后 at -c ...

  8. redhat quay 安装试用

    最近redhat 开源了quay 容器镜像管理平台,参考官方文档跑的时候需要订阅,各种不好使,然后就自己基于源码构建了 一个镜像(使用官方的dockerfile,构建出来的太大了1.9G 以及push ...

  9. django @login_required登录限制

    参考文章:https://www.cnblogs.com/wodekaifalog/p/10817275.html 我们在网站开发过程中,经常会遇到这样的需求: 用户登陆系统才可以访问某些页面 如果用 ...

  10. 关于微信订阅号里自动回复里的a链接的问题

    前阵子做了一个微信订阅号的活动,然后发现一个问题:就是回复内容里的a标签微信没有解析出来,而是这样 正常应该是这样: 具体出现这种情况的手机有: 魅族的型号是:M1 metal小米的型号是:MI 5X ...