Supporting GPUs in
Docker Containers on Apache Mesos
MesosCon Europe - 2016
Kevin Klues
Senior Software Engineer
Mesosphere
Yubo Li
Staff Researcher
IBM Research China
Kevin Klues
Yubo Li
Kevin Klues is a Senior Software Engineer at Mesosphere working on the Mesos core team. Since joining Mesosphere, Kevin has been involved in the design and implementation of a number of Mesos’s core subsystems, including GPU isolation and Pods. When not working, you can usually find Kevin on a snowboard or up in the mountains in some capacity or another.
Dr. Yubo Li is a Staff Researcher at IBM Research, China. He is the architect of the GPU acceleration and deep-learning as a service (Dlaas) components of SuperVessel, an open-access cloud running OpenStack on OpenPOWER machines. He is currently working on GPU support for several cloud container technologies, including Mesos, Kubernetes, Marathon and Open Stack.
Email: liyubobj@cn.ibm.com
Slack: @liyubobj
Email: klueska@mesosphere.com
Slack: @klueska
Why GPUs?
3
Why GPUs?
4
Credit: www.slideshare.net/DataScienceMD/deep-learning-with-gpus
Why GPUs?
5
Why GPUs?
6
Why GPUs?
7
Unified Job
Scheduler
Why GPUs?
8
METRONOME
(Batch)
MARATHON
(Long Running)
ON-PREMISE
GPU-Accelerated
Node
CLOUD
GPU-Accelerated
Node
Source: www.nvidia.com/object/apache-mesos.html
Why Docker?
9
Source: DockerCon 2016 Keynote by Docker’s CEO Ben Golub
Image Pulls
Dockerized Applications
Why Docker?
Nvidia-docker
Wrapper around docker to allow GPUs to be used inside docker containers
10
Source: https://devblogs.nvidia.com/parallelforall/nvidia-docker-gpu-server-application-deployment-made-easy/
Why Docker?
Machine Learning Frameworks
Support exists for many popular machine learning frameworks with nvidia-docker (including TensorFlow, Caffe, CNTK, etc.)
11
Source: https://data-shaker.com/docker-tensorflow-with-jupyter-notebook-on-windows/
Overall Goal
Test locally with nvidia-docker
Deploy to production with Mesos
12
Overview of Talk
13
Challenges of Supporting Nvidia GPUs in Docker containers
14
Challenges of Supporting Nvidia GPUs in Docker containers
15
Challenges of Supporting Nvidia GPUs in Docker containers
16
Linux Kernel
Challenges of Supporting Nvidia GPUs in Docker containers
17
nvidia base libraries
Linux Kernel
nvidia-kernel-module
Challenges of Supporting Nvidia GPUs in Docker containers
18
nvidia base libraries
CUDA / TensorFlow libraries
Linux Kernel
nvidia-kernel-module
Challenges of Supporting Nvidia GPUs in Docker containers
19
nvidia base libraries
CUDA / TensorFlow libraries
Application
Linux Kernel
nvidia-kernel-module
Challenges of Supporting Nvidia GPUs in Docker containers
20
nvidia base libraries
CUDA / TensorFlow libraries
Application
Linux Kernel
nvidia-kernel-module
Challenges of Supporting Nvidia GPUs in Docker containers
21
Linux Kernel
nvidia-kernel-module
Challenges of Supporting Nvidia GPUs in Docker containers
22
Container
Linux Kernel
nvidia-kernel-module
nvidia base libraries
CUDA / TensorFlow libraries
Application
Challenges of Supporting Nvidia GPUs in Docker containers
23
Container
Linux Kernel
nvidia-kernel-module
nvidia base libraries
CUDA / TensorFlow libraries
Application
Challenges of Supporting Nvidia GPUs in Docker containers
24
Container
Linux Kernel
nvidia-kernel-module
nvidia base libraries
CUDA / TensorFlow libraries
Application
Challenges of Supporting Nvidia GPUs in Docker containers
25
Linux Kernel
nvidia-kernel-module (v1)
Linux Kernel
nvidia-kernel-module (v2)
Container
nvidia base libraries (v1)
CUDA / TensorFlow libraries
Application
Challenges of Supporting Nvidia GPUs in Docker containers
26
Linux Kernel
nvidia-kernel-module (v1)
Linux Kernel
nvidia-kernel-module (v2)
Container
nvidia base libraries (v1)
CUDA / TensorFlow libraries
Application
Challenges of Supporting Nvidia GPUs in Docker containers
27
Linux Kernel
nvidia-kernel-module (v1)
Linux Kernel
nvidia-kernel-module (v2)
Container
nvidia base libraries (v1)
CUDA / TensorFlow libraries
Application
nvidia-docker and GPUs
28
docker run ...
nvidia-docker run ...
nvidia-docker and GPUs
Finds all standard nvidia libraries / binaries on the host and consolidates them into a single place as a docker volume
/var/lib/docker/volumes
└── nvidia_XXX.XX (version number)
├── bin
├── lib
└── lib64
29
nvidia-docker and GPUs
Looks for the label:
com.nvidia.volumes.needed = nvidia_driver
When found, it maps the nvidia_XXX.XX volume into the container at:
/usr/local/nvidia
Enumerates all GPUs on the machine and maps them into the container as available devices
Passes all other docker options straight through to docker
30
nvidia-docker and GPUs
31
Linux Kernel
nvidia-kernel-module (v1)
Linux Kernel
nvidia-kernel-module (v2)
Container
nvidia base libraries (v1)
CUDA / TensorFlow libraries
Application
nvidia base libraries (v2)
Container
CUDA / TensorFlow libraries
Application
nvidia-docker and GPUs
32
Linux Kernel
nvidia-kernel-module (v1)
Linux Kernel
nvidia-kernel-module (v2)
Container
nvidia base libraries (v1)
CUDA / TensorFlow libraries
Application
nvidia base libraries (v2)
Container
CUDA / TensorFlow libraries
Application
Apache Mesos and GPUs
33
Apache Mesos and GPUs
34
Apache Mesos and GPUs
35
Apache Mesos and GPUs
36
(Unified) Mesos Containerizer
Containerizer API
Mesos Agent
Isolator API
CPU
Memory
Apache Mesos and GPUs
37
(Unified) Mesos Containerizer
Containerizer API
Mesos Agent
Isolator API
CPU
Memory
GPU
Apache Mesos and GPUs
38
(Unified) Mesos Containerizer
Containerizer API
Mesos Agent
Isolator API
CPU
Memory
GPU
Nvidia GPU Isolator
Linux devices cgroup
Nvidia GPU
Allocator
Apache Mesos and GPUs
39
(Unified) Mesos Containerizer
Containerizer API
Mesos Agent
Isolator API
CPU
Memory
GPU
Nvidia GPU Isolator
Linux devices cgroup
Nvidia GPU
Allocator
Nvidia Volume
Manager
Mimics functionality of nvidia-docker-plugin
Apache Mesos and GPUs
40
(Unified) Mesos Containerizer
Containerizer API
Mesos Agent
Isolator API
CPU
Memory
GPU
Linux devices cgroup
Nvidia GPU
Allocator
Nvidia Volume
Manager
Nvidia GPU Isolator
Apache Mesos and GPUs
41
Docker Containerizer
Containerizer API
Mesos Agent
Isolator API
CPU
Memory
(Unified) Mesos Containerizer
GPU
Composing Containerizer
Nvidia GPU
Allocator
Nvidia Volume
Manager
GPU
Implementation Timeline
42
Looking forward
43
Special Thanks to All Collaborators
44
Vikram Ditya Andrew Iles Jonathan Calmels Felix Abecassis Rob Todd Rajat Phull Shivi Fotedar | Seetharami Seelam Yong Feng Guangya Liu Ian Downes Niklas Nielson Connor Doyle Benjamin Mahler Tim Chen |
ISOLATION
DEMO
45
https://github.com/klueska-mesosphere/mesos-gpu-docker
46
DEMO
FROM IBM
47