You can develop a custom kernel locally, and then build it for multiple architectures and make it available for the world to use. Now that our kernel and its bindings are ready, it's time to build them. For example, to build our kernel for PyTorch 2.7 with CUDA 12.6, we can use the following command: This process may take a while, as it will build the kernel for all supported versions of PyTorch and CUDA.
Custom CUDA kernels give your models a serious performance edge, but building them for the real world can feel daunting. How do you move beyond a simple GPU function to create a robust, scalable system without getting bogged down by endless build times and dependency nightmares?
We created the kernel-builder library for this purpose. You can develop a custom kernel locally, and then build it for multiple architectures and make it available for the world to use.
In this guide we'll show you how to build a complete, modern CUDA kernel from the ground up. Then, we’ll tackle the tough production and deployment challenges, drawing on real-world engineering strategies to show you how to build systems that are not just fast, but also efficient and maintainable.
At this point, we'll be inside a Nix shell with all dependencies installed. We can now build the kernel for this particular architecture and test it. Later on, we'll deal with multiple architectures before distributing the final version of the kernel.
You can build your kernel with a single command, nix build . -L ; however, as developers, we'll want a faster, more iterative workflow. For that, we'll use the nix develop command to enter a development shell with all the necessary dependencies pre-installed.
When you're done, other developers will be able to use your kernels directly from the hub like this:
Let's build a practical kernel that converts an image from RGB to grayscale. This example uses PyTorch's modern C++ API to register our function as a first-class, native operator.
A clean, predictable structure is the foundation of a good project. The Hugging Face Kernel Builder expects your files to be organized like this:
From Zero to GPU: A Guide to Building and Scaling Production-Ready CUDA Kernels. Covered by Hugging Face on August 18, 2025.