Docker GPU Access – Why GPUs Are Accessible from Docker Containers on Linux but Not on Windows or MacOS

dockergpulinuxvirtual-machinesvirtualization

Recent versions of docker (or any version of nvidia-docker) allow direct(?) access to the host GPU from within docker containers, with full access to CUDA APIs. This is very convenient when deploying complex machine learning inference servers.

However, currently only Linux hosts are supported as far as I can tell.

Why can't Microsoft and Apple step up their game and provide the same level of support? Which is to say, what trick is being used on Linux, which is apparently hard to imitate in other OSes?

Best Answer

Docker on linux uses the hosting kernel directly, but Docker on Windows actually runs in a VM (hosted by Hyper-V in Windows) because Windows doesn't have a linux kernel for Docker to directly interact with. So reaching the host GPU from a docker container on Windows then requires reaching out from the docker container in the guest VM into the hosting Windows OS to communicate with the GPU drivers. A lot of special development from Microsoft and the GPU manufacturer is required to support all that properly.