π Read more: .
π Official doc for TF + docker.
π Note about Docker and Tensorflow: Tensorflow.
π An example of docker pytorch with gpu support.
π Note about Docker and Tensorflow: Tensorflow.
π An example of docker pytorch with gpu support.
You must (successfully) install the GPU driver on your (Linux) machine before proceeding with the steps in this note. Go to the "Check info" section to check the availability of your drivers.
(Maybe just for me) It works perfectly on Pop!_OS 20.04, I tried it and we have a lot of problems with Pop!_OS 21.10 so stay with 20.04!
If you have problems installing 
nvidia-docker2, read this section!If below command doesn't work, try to install 
nvidia-docker2 (read this section).π (Should follow this for the up-to-date) Officicial guide to install.
Note: (Only for me) Use the codes below.
In this note, with Docker 19.03+ (docker --version), he says thatnvidia-container-toolkitis used for--gpus(indocker run ...),nvidia-container-runtimeis used for--runtime=nvidia(can also be used in docker-compose file).
However, if you want to use Kubernetes with Docker 19.03, you actually need to continue using nvidia-docker2 because Kubernetes doesn't support passing GPU information down to docker through the--gpusflag yet. It still relies on the nvidia-container-runtime to pass GPU information down the stack via a set of environment variables.
Purpose?
π Check more in my repo my-dockerfiles on Github.
Run the test,
Without using 
docker-compose.yml (tensorflow) (cf. this note for more)With 
docker-compose.yml?Then run,
π Check this answer as a reference!
π Use a GPU.
Problems with pytorch versions: check this.
RuntimeError: cuda runtime error (804) : forward compatibility was attempted on non supported HW at /pytorch/aten/src/THC/THCGeneral.cpp:47 (after update system including nvdia-cli, maybe) => The same problem with below, need to restart the computer.
nvidia-smi: Failed to initialize NVML: Driver/library version mismatch.This thread: just restart the computer.
This section still works (on 26-Oct-2020), but it's obselete for newer methods.
One idea: Use NVIDIA driver of the base machine, don't install anything in Docker!
- Dockerfile on Github of Tensorflow.