博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NVIDIA-docker Cheatsheet
阅读量:5011 次
发布时间:2019-06-12

本文共 4021 字,大约阅读时间需要 13 分钟。

TensorFlow Docker requirements

  1.  on your local host machine.
  2. For GPU support on Linux, .

Note: To run the docker command without sudo, create the docker group and add your user. For details, see the .

Download a TensorFlow Docker image

The official TensorFlow Docker images are located in the  Docker Hub repository. Image releases  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. ()
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 .

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  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  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  (the NVIDIA® CUDA® Toolkit is not required).

Install  to launch a Docker container with NVIDIA® GPU support. nvidia-docker is only available for Linux, see their  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
 

转载于:https://www.cnblogs.com/sddai/p/11116349.html

你可能感兴趣的文章
HDOJ 5630 Rikka with Chess
查看>>
netcore2.1 在后台运行一个任务
查看>>
PostgreSQL pg_hba.conf 文件简析
查看>>
android o logcat read: unexpected EOF!
查看>>
[Scrum]2010/12/28 —— 第一天!
查看>>
ASP.NET MVC模式 温习(一)排除MVC模式误区
查看>>
Mysql的read_only 只读属性说明 (运维笔记)
查看>>
DOCKER 从入门到放弃(五)
查看>>
Python 多线程学习
查看>>
appcan官方ajax
查看>>
获取NVIDIA显卡的温度
查看>>
Dijkstra算法
查看>>
Deep Learning 9: Performance
查看>>
面试题61 把二叉树打印成多行
查看>>
C#例子 易懂故事 接口 委托 事件 异步通知 好玩.
查看>>
[转]Windows Shell 编程 第十一章 【来源:http://blog.csdn.net/wangqiulin123456/article/details/7987992】...
查看>>
修改presto新版源码让他支持redash数据库
查看>>
Javascript的书写位置
查看>>
树-线索二叉树
查看>>
JAVA遇见HTML——Servlet篇:Servlet基础
查看>>