1 # Building HAT (NVidia Notes)
2 [Back to Index ../](../index.md)
3
4 This guide provides step-by-step instructions to configure Babylon/HAT for CUDA-based GPU acceleration.
5
6 ### Prerequisites
7
8 To run Babylon/HAT with the CUDA backend, ensure the following components are properly installed:
9
10 1. **The NVIDIA GPU Driver:** Download and install the latest appropriate driver for your operating system from the [NVIDIA Drivers page](https://www.nvidia.com/en-us/drivers/)
11 2. **The CUDA Toolkit (SDK):** Download the matching CUDA Toolkit from the [NVIDIA CUDA Downloads page](https://developer.nvidia.com/cuda-downloads).
12
13 The CUDA Toolkit version must be compatible with your installed NVIDIA driver.
14 For example, as of June 2025, the stable NVIDIA driver for Linux is `570.169`, which supports CUDA Toolkit version `12.8`.
15
16 Always verify compatibility before installation to prevent runtime errors:
17 - You can find previous CUDA Toolkit versions on the [NVIDIA CUDA Toolkit Archive](https://developer.nvidia.com/cuda-toolkit-archive)
18 - Review supported CUDA versions and PTX ISA implementations in the [NVIDIA Parallel Thread Execution documentation](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#release-notes).
19
20
21 ### Troubleshooting: Unsupported CUDA/PTX Versions
22
23 If Babylon/HAT runs with an incompatible CUDA/PTX version, you may encounter an error similar to:
24
25 ```bash
26 cuModuleLoadDataEx CUDA error = 222 CUDA_ERROR_UNSUPPORTED_PTX_VERSION
27 /<path/to/babylon>/hat/backends/ffi/cuda/src/main/native/cpp/cuda_backend.cpp line 220
28 ```
29
30 If this is your case, you can:
31 - **update your GPU driver**.
32 - **or downgrade your CUDA version.**
33
34 ### Building HAT for the CUDA backend
35
36 If the NVIDIA driver and the CUDA Toolkit SDK are installed, the HAT build process will automatically compile
37 all sources to dispatch with the CUDA backend.
38
39 ```bash
40 mvn clean package
41 ```
42
43 ### Run HAT examples with the CUDA Backend
44 You can enable the CUDA backend by using the `ffi-cuda` option from HAT.
45 For example, to run the Matrix Multiplication example:
46
47 ```bash
48 java @.ffi-cuda-examples matmul.Main 1D
49 ```