Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

First check that the container image is available using the docker image ls command:

Code Block
languagebashnone
$ docker image ls
REPOSITORY        TAG                       IMAGE ID       CREATED         SIZE
lambda-stack      20.04                     abe4a492cee1   6 hours ago     12GB
ubuntu            latest                    df5de72bdb3b   3 weeks ago     77.8MB
ubuntu            20.04                     3bc6e9f30f51   3 weeks ago     72.8MB
debian            latest                    07d9246c53a6   3 weeks ago     124MB
nvidia/cuda       11.0.3-base-ubuntu20.04   8017f5c31b74   5 weeks ago     122MB
hello-world       latest                    feb5d9fea6a5   11 months ago   13.3kB

...

To start a program in the container, use the docker run --rm command:

Code Block
languagebashnone
$ docker run --rm lambda-stack:20.04 ls
TODO add output

...

To run an interactive command like bash or python interpreter, add the -it flag:

Code Block
languagebashnone
$ docker run --rm -it lambda-stack:20.04 bash
TODO add output

...

Code Block
breakoutModewide
languagebashnone
$ docker run --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0,1 --rm lambda-stack:20.04 nvidia-smi
TODO output

...

For example, assuming you have a project folder in $HOME/my_project and want to access it as /my_project in the container, you would use:

Code Block
languagebashnone
$ docker run -v $HOME/my_project:/my_project --rm lambda-stack:20.04 ls /
TODO output

...

In the following Dockerfile example, the Transformers library (PyTorch version) from Hugging Face is added to the LambdaStack container:

Code Block
languagenone
FROM lambda-stack:20.04
RUN pip install pip install transformers[torch]

To build the corresponding container, first create an empty folder and save the Dockerfile in it:

Code Block
languagebashnone
$ mkdir hugging_container
$ echo "FROM lambda-stack:20.04" > hugging_container/Dockerfile
$ echo "pip install pip install transformers[torch]" >> hugging_container/Dockerfile

then use the docker build command to generate the new container:

Code Block
languagebashnone
$ cd hugging_container
$ docker build -t $USER/huggingpytorch-transformers .

TODO list imageThe -t flag is used to tag the container, making it easier to find and use it later.

Use docker image ls to check the availability of the image:

Code Block
$ docker image ls
TODO output

You can now use it in place of the LambdaStack container:

Code Block
breakoutModewide
$ docker run --rm pytorch-transformers \
    python -c "import "from transformers import pipeline; print(pipeline('sentiment-analysis')('I love you'))"
TODO output

Next steps

TODO list references to go beyond the basics