Key Concepts:

GPU acceleration in containers

How can GPU acceleration be used to perform rendering or computational tasks inside Linux and Windows containers?

Key points:

Contents

Graphics APIs

Modern graphics hardware supports a variety of functionality including traditional rasterisation for rendering 2D or 3D graphics, raytracing for generating realisting lighting and reflections, video encoding and decoding, AI acceleration for machine learning tasks and GPGPU pipelines for general purpose computation. Each of these features are exposed to software through different Application Programming Interfaces (APIs) on different platforms, and understanding the purpose of these APIs is helpful when discussing GPU acceleration in the context of containers.

The following APIs are used for rendering (rasterisation and raytracing):

The following APIs are used for encoding and decoding video:

The following APIs are used for machine learning tasks and general purpose computation:

The set of graphics APIs that are available to software running inside a container determines which GPU features it can access. The availability of these APIs varies based on operating system and hardware vendor. Note that if you are unable to make use of GPU acceleration for a given configuration then it may still be possible to fall back to software rendering as an alternative.

NVIDIA GPU support for Linux containers

Linux containers can access full GPU acceleration on NVIDIA graphics hardware using the NVIDIA Container Toolkit, which is described in further detail on its dedicated page. The following graphics APIs are supported:

AMD GPU support for Linux containers

The authors of this documentation are still in the process of familiarising themselves with AMD GPU acceleration in Linux containers. This section will be updated when the relevant information has been gathered.

GPU support for Windows containers

Windows containers can access limited GPU acceleration on graphics hardware from any vendor using native hardware acceleration support, so long as the graphics drivers are compliant with Windows Display Driver Model (WDDM) version 2.5 or newer. The following graphics APIs are supported by default:

It is possible to enable support for additional graphics APIs as described in the blog post Enabling vendor-specific graphics APIs in Windows containers. Please note that using graphics APIs other than DirectX inside Windows containers is not officially supported by Microsoft and is not recommended for production use. However, it does make it possible to access graphics APIs for encoding and decoding video, which allows Windows containers to be used for tasks that require hardware accelerated video encoding such as running Pixel Streaming applications.

For an example of a Windows container image suitable for use with GPU acceleration, see the blog post Offscreen rendering in Windows containers.

Software rendering

Software rendering can be used as a fallback option in situations where access to graphics APIs for rendering is required but the real-time rendering performance of a GPU is not necessary.

Software rendering in Linux containers

The authors of this documentation are still in the process of familiarising themselves with OpenGL and Vulkan software rendering in Linux containers. This section will be updated when the relevant information has been gathered.

Software rendering in Windows containers

Under Windows, you can perform software rendering using the Windows Advanced Rasterization Platform (WARP), which ships with DirectX. To use WARP when running the Unreal Editor or a packaged Unreal project, specify the -warp command-line flag. This flag is supported when using the Direct3D 12 rendering backend in Unreal Engine version 4.14.0 and newer. (You can also use the -dx12 command-line flag to force the use of the Direct3D 12 rendering backend for Unreal projects which are not configured to use it by default.)

Note that you will still need to use a Windows container image that includes the DLL files for DirectX support in order to use WARP inside a container. As a result, Windows container images suitable for use with GPU acceleration are also suitable for use with software rendering.