Ceci est une ancienne révision du document !


Using docker with GPU

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package

In this tutorial we will learn how to use docker with GPU by running a simple Tesnforflow program.

We will the latest TF GPU images. Firts we check if the image exist locally:

$ docker images
...
tensorflow/tensorflow       latest-gpu          85020a337138        2 days ago          
5.63GB
...

We can pull the image if it doesn't exist :

$ docker pull tensorflow/tensorflow:latest-gpu

Before running a container, we suppose that we have a folder named app containing our tensorflow program.

$ ls .
app 

Lets open a shell within the container:

$ nvidia-docker run -it --rm tensorflow/tensorflow:latest-gpu 
root@af31168ce2e5:/notebooks# 

Woot! we gain root shell inside the container!

  • -it means interactive
  • – rm means delete the container when finished

Newt we try to list files inside the container:

root@af31168ce2e5:/notebooks#ls  
1_hello_tensorflow.ipynb  2_getting_started.ipynb  3_mnist_from_scratch.ipynb  BUILD  LICENSE

These files are inside the containers. Host files (app folder) are not visible inside the container. We will see later how to expose theme.

We can run directly python shipped withe container:

$ nvidia-docker run -it --rm tensorflow/tensorflow:latest-gpu python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf

Lets try to access to our folder app inside the container:

$ nvidia-docker run -it --rm  -v app:/app tensorflow/tensorflow:latest-gpu bash
# ls /app 
tfexample.py   
  • deeplearning/docker.1548427652.txt.gz
  • Dernière modification : 2019/01/25 14:47
  • de admin