Getting Nvidia GPU to work on Ubuntu
Jan 5, 2023
[Huy Le]
2 minute read
WIKI LAYOUT

THIS IS THE MOST IMPORTANT ARTICLE TO READ! - https://devblogs.nvidia.com/gpu-containers-runtime/

The basics of Dockers #

  • docker images - the actual file for the container, this shows all the images that have been downloaded
  • docker containers - the instance of the images
  • docker ps -a - list all the containers, even the ones that are stopped
  • docker start <container-name> - will start a stopped container
  • docker stop <container-name> - will stop a running container
  • the --rm - argument will destroy the container as soon as it is stopped

Docker compose #

  • docker-compose up - spin up a docker container using docker-compose.yml

Installing #

Executing nvidia-docker #

  • remember to workon tensorflow –> this will activate the python virtualenv for us to use Tensorflow

  • running docker in the background nvidia-docker run -d -it -p -v .:/notebooks 8888:8888 tensorflow/tensorflow:latest-gpu

    • this will run docker detached, and mount the current working directory to /notebooks
  • faster execution of dockers

    • use docker-compose up which will read all the content of docker-compose.yml file
    • At the moment we are using nvidia-docker which has a nvidia-docker-compose library, but it is not updated to nvidia-docker version –> 2.0.3
    • If you try to run docker-compose on an nvidia-docker project, you will get an error. import tensorflow as tf wont work

Issues #

  • have to use the alias tf to launch to keep the command line typing to a min
    • eventually, this can be run using nvidia-docker-compose for this version of nvidia-docker is supported

Resources #