Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is GPU pass-through possible with docker for Windows?

I am trying to run an application inside a docker container in Windows 10.

But I am not able to get the GPU working inside docker.

I read that it needs "GPU Pass-through."

How should I get around this?

like image 884
Srihari Humbarwadi Avatar asked Mar 31 '18 15:03

Srihari Humbarwadi


People also ask

Can Windows Docker use GPU?

Last, the GPU support has been merged in Docker Desktop (in fact since version 3.1).

Can containers use GPU?

Key points: Linux containers support all graphics APIs for NVIDIA GPUs using the NVIDIA Container Toolkit. Windows containers support DirectX-based graphics APIs for GPUs from all vendors using native hardware acceleration support.

Can Windows be Dockerized?

You can run any application in Docker as long as it can be installed and executed unattended, and the base operating system supports the app. Windows Server Core runs in Docker which means you can run pretty much any server or console application in Docker.

Can two Docker containers share a GPU?

is it possible to share a GPU between multiple containers? I checked FAQs and the answer is yes, but the issue from kubernetes has investigated that nvidia-docker2 fails to achieve this.


2 Answers

Update (December 2020) You can now do GPU pass-through on Windows, if you use WSL 2 as the backend for Docker: WSL 2 GPU Support is Here - that is a slightly neater method than running Docker inside WSL.

Original answer:

GPU access from within a Docker container currently isn't supported on Windows.

You need nvidia-docker, but that is currently only supported on Linux platforms. GPU passthrough with Hyper-v would require Discrete Device Assignment (DDA), which is currently only in Windows Server, and (at least in 2015) there was no plan to change that state of affairs. Hence, NVIDIA are not porting nvidia-docker to Windows at the moment.

A bit more info here: https://devblogs.nvidia.com/nvidia-docker-gpu-server-application-deployment-made-easy/

Update (October 2019): nvidia-docker is deprecated, as Docker 19.03 has native support for NVIDIA GPUs. Instead install nvidia-container-runtime, and use the docker run --gpus all flag. You can also run Windows Containers with GPU acceleration on a Windows host, using Docker 19.03, but not a Linux container.

Update (August 2020): It looks like you can now do GPU pass-through when running Docker inside the Windows Subsystem for Linux (WSL 2).

This link goes through installation, setup and running a TensorFlow Jupyter notebook inside Docker in Ubuntu in WSL 2, with GPU support: https://ubuntu.com/blog/getting-started-with-cuda-on-ubuntu-on-wsl-2

Note - I haven't done this myself yet.

like image 67
4Oh4 Avatar answered Sep 26 '22 08:09

4Oh4


Now that docker on Windows 10 can access WSL2 (as of Windows 10 version 2004) it has cleared the way for GPU support of Linux docker containers on Windows 10.

According to this official blog, MS "will start previewing GPU compute support for WSL in Windows 10 Insider builds within the next few months": https://devblogs.microsoft.com/commandline/the-windows-subsystem-for-linux-build-2020-summary/#wsl-gpu

I expect Docker GPU support to follow shortly after.

Update:

GPU pass-through in Windows is now possible under very specific circumstances, including:

  • that the container must be Windows as well
  • process level isolation only, no hyper-v
  • it only works with DirectX based applications
  • for Machine Learning, this means only Microsoft ML will work.

Refer to: https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/gpu-acceleration

Update 2:

GPU pass through from Linux docker on Windows host is now possible on the latest Windows Insider build, refer to:

https://ubuntu.com/blog/getting-started-with-cuda-on-ubuntu-on-wsl-2

This will flow through to mainstream Windows probably in the next major update.

Update 3:

Confirmed that Windows build version 2021 will include GPU pass-through for WSL. See details of the announcement here: https://blogs.windows.com/windowsdeveloper/2021/05/25/the-windows-developers-guide-to-microsoft-build-2021/

like image 27
James Mc Avatar answered Sep 26 '22 08:09

James Mc