Skip to content

Instantly share code, notes, and snippets.

@fengye
Last active February 18, 2018 11:25
Show Gist options
  • Save fengye/dea9180b2b8f6e22e5ae25ad33d9acac to your computer and use it in GitHub Desktop.
Save fengye/dea9180b2b8f6e22e5ae25ad33d9acac to your computer and use it in GitHub Desktop.

Based on the instruction here https://github.com/gw0/docker-keras with a few modification on how to run on GPU:

The original snippet:

$ docker run -it --rm $(ls /dev/nvidia* | xargs -I{} echo '--device={}') $(ls /usr/lib/*-linux-gnu/{libcuda,libnvidia}* | xargs -I{} echo '-v {}:{}:ro') -v $(pwd):/srv gw000/keras:2.1.4-py2-tf-gpu /srv/run.py

The idea is to map local NVIDIA devices(/dev/nvidia*) to container environment, and map local NVIDIA drivers and libraries to proper container's /usr/lib/ directories. With NVIDIA driver 387.34(latest when written), this is snippet is no longer sufficient.

Modified snippet:

$ docker run -it --rm $(ls /dev/nvidia* | xargs -I{} echo '--device={}') $(ls /usr/lib/*-linux-gnu/{libcuda,libnvidia}* /usr/lib/nvidia*/*.so* | xargs -I{} echo '-v {}:{}:ro') -v $(pwd):/srv -e LD_LIBRARY_PATH=/usr/lib/nvidia-387 gw000/keras:2.1.4-py3-tf-gpu

So adding /usr/lib/nvidia*/*.so* to file mapping and putting /usr/lib/nvidia-387 into LD_LIBRARY_PATH environment variable.

I'm still trying to fetch the driver version from /proc/driver/nvidia/version and pass to docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment