Is GPU pass-through possible with docker for Windows?

前端 未结 4 1506
半阙折子戏
半阙折子戏 2021-02-04 02:02

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 Pa

相关标签:
4条回答
  • 2021-02-04 02:42

    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.

    0 讨论(0)
  • 2021-02-04 02:52

    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.

    0 讨论(0)
  • 2021-02-04 02:57

    Note that Hardware Acceleration of video decoding-encoding is not supported in the WSL2/windows-Insider implementation.

    Thus, any GPU functions can be used with little limitations on WSL2 but video encoding-decoding cannot be done by the hardware.

    Attempt to ask ffmpeg to use the hardware acceleration leads to error messages. (skvideo, which is an ffmpeg wrapper, crashes)

    Not sure about gStreamer yet. But for sure it cannot use the Hardware Acceleration as it is not "funneled" through the interface.

    As far as I know - there are no current plans to add ths support.

    Best, Mickey

    0 讨论(0)
  • 2021-02-04 03:08

    Provide a sample !

    ffmpeg -hide_banner -codecs | grep 264
    DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m h264_cuvid ) (encoders: h264_nvenc h264_v4l2m2m nvenc nvenc_h264 )
    

    This would show that the ffmpeg verion can handle: h264_nvenc nvenc nvenc_h264

    ffmpeg -i video.mp4 -vf scale=iw/2:ih/2 -vcodec h264_nvenc "video_2.mp4"
    

    On my WSL2/Insider I get a message that I don't have the correct nvidia driver installed. Because the drive is installed down-below in the windows OS.

    Queries with Microsoft and NVIDIA turned out the hardware acceleration is not passed through and they have no near future plans to do so.

    Windows docker on a widnows os, could be fine. Will check.

    0 讨论(0)
提交回复
热议问题