Add Machine Learning to Your C Code with DirectML
Modern GPUs have evolved far beyond their original role in rendering graphics. Technologies like OpenCL and Nvidia’s CUDA have unlocked their potential as parallel computing powerhouses, enabling desktop PCs to handle tasks once reserved for supercomputers. These GPUs are now integral to a wide range of applications, including machine learning, where they play a crucial role in building and training neural networks, as well as supporting data-parallel tasks.
Microsoft has long been dedicated to simplifying GPU programming, starting with its DirectX suite of tools. From Direct3D for graphics to DirectCompute for GPU compute tasks, Microsoft has worked to make powerful GPU capabilities more accessible to developers. Recent innovations, such as mapping OpenGL calls to Direct3D and integrating graphics into the WSL 2 Linux subsystem for Windows 10, have further expanded the possibilities for working with GPUs. However, these tools still required low-level programming and were primarily targeted at C++ developers.
The introduction of DirectML, a new addition to the DirectX family of GPU APIs, marks a significant shift in how machine learning can be integrated into applications. DirectML simplifies the process by providing high-performance machine learning primitives that can be directly used in custom code or through Microsoft’s own libraries. While earlier versions required intricate Direct3D metacommands and shader operators to access device-specific features, DirectML abstracts those complexities, allowing developers to use a standardized set of tools that work across different GPU vendors.
One of the most exciting aspects of DirectML is its ability to bring GPU-accelerated machine learning to Windows environments, including WSL (Windows Subsystem for Linux). By exposing DirectML to WSL, Microsoft makes it easier for developers to leverage GPU power for machine learning tasks without needing separate drivers for Linux and Windows. This innovation also supports the integration of popular machine learning frameworks like TensorFlow, making it more practical for developers to build and test ML applications in cross-platform environments. The addition of DirectML, bundled as a single NuGet package, enhances the accessibility of GPU-based machine learning for both Win32 and UWP applications, and allows WSL users to take full advantage of GPU capabilities.