Loading page

Verify your DGX Spark environment

Before compiling llama.cpp, confirm your CPU architecture, heterogeneous Grace core topology, unified memory capacity, and CUDA 13 toolkit.

Check the CPU architecture, core topology, and available memory:

    

        
        
uname -m
lscpu | grep -E "Model name|CPU\(s\)|Core|Socket"
free -h

    

Confirm that uname -m prints aarch64 and that lscpu lists 20 CPU cores. They comprise 10 Arm Cortex-X925 performance cores and 10 Arm Cortex-A725 efficiency cores.

Inspect which logical CPU IDs map to Cortex-X925 versus Cortex-A725:

    

        
        
lscpu -e=CPU,CORE,MAXMHZ,MODELNAME

    

The output is similar to:

    

        
        CPU CORE    MAXMHZ MODELNAME
  0    0 2808.0000 Cortex-A725
...
  5    0 3900.0000 Cortex-X925
...
 15    5 3900.0000 Cortex-X925
 19    9 3900.0000 Cortex-X925

        
    

Confirm that the NVIDIA GB10 GPU driver and CUDA compiler are available. Add /usr/local/cuda/bin to your PATH if nvcc isn’t already on your default path:

    

        
        
export PATH=/usr/local/cuda/bin:$PATH
nvidia-smi
nvcc --version

    

The output is similar to:

    

        
        | NVIDIA-SMI 580.178.04             Driver Version: 580.178.04     CUDA Version: 13.0     |
...
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |
...
Cuda compilation tools, release 13.0, V13.0.88

        
    

Install build prerequisites

Update your package index and install the compiler toolchain, CMake, Git, libcurl development headers, and Python virtual environment tools:

    

        
        
sudo apt update
sudo apt install -y build-essential cmake git libcurl4-openssl-dev python3-venv python3-pip

    

Clone and build llama.cpp

Create a dedicated project directory and clone the official llama.cpp repository:

    

        
        
mkdir -p ~/hermes-gemma4 && cd ~/hermes-gemma4
git clone https://github.com/ggml-org/llama.cpp.git
cd llama.cpp

    

Configure CMake to build both the CUDA GPU backend and an optimized Arm KleidiAI CPU backend in one binary set:

    

        
        
export PATH=/usr/local/cuda/bin:$PATH

cmake -B build \
  -DCMAKE_BUILD_TYPE=Release \
  -DGGML_CUDA=ON \
  -DCMAKE_CUDA_ARCHITECTURES=121a-real \
  -DGGML_NATIVE=OFF \
  -DGGML_CPU_ARM_ARCH=armv9-a+dotprod+i8mm+bf16+sve+sve2+fp16 \
  -DGGML_OPENMP=ON \
  -DGGML_CPU_KLEIDIAI=ON

    

Inspect the CMake configuration output to confirm that all Armv9.2 CPU feature checks pass alongside CUDA and Flash Attention:

    

        
        -- Checking for ARM features using flags:
--   -march=armv9-a+dotprod+i8mm+bf16+sve+sve2+fp16
-- Performing Test HAVE_DOTPROD - Success
-- Performing Test HAVE_SVE - Success
-- Performing Test HAVE_MATMUL_INT8 - Success
-- Performing Test HAVE_FMA - Success
-- Performing Test HAVE_FP16_VECTOR_ARITHMETIC - Success
-- Using KleidiAI optimized kernels if applicable
-- CUDA Toolkit found
-- Using CMAKE_CUDA_ARCHITECTURES=121a-real CMAKE_CUDA_ARCHITECTURES_NATIVE=121a-real
-- FlashAttention K-V type combinations: f16-f16;q4_0-q4_0;q8_0-q8_0;bf16-bf16;f8_e4m3-f8_e4m3
-- Including CUDA backend

        
    
Important

Don’t rely on -DGGML_NATIVE=ON with the Ubuntu 24.04 default GNU Compiler Collection (GCC) 13.3.0 on DGX Spark. GCC 13 predates Cortex-X925 and Cortex-A725 CPU identification. -mcpu=native therefore leaves -march empty and causes HAVE_DOTPROD, HAVE_MATMUL_INT8, HAVE_SVE, and HAVE_FP16_VECTOR_ARITHMETIC feature probes to fail.

Passing -DGGML_NATIVE=OFF with -DGGML_CPU_ARM_ARCH=armv9-a+dotprod+i8mm+bf16+sve+sve2+fp16 enables every Grace Armv9.2 instruction extension and Arm KleidiAI microkernel.

The key CMake options control the following features on DGX Spark:

FlagPurpose
-DGGML_CUDA=ONEnables the CUDA backend for NVIDIA GPU offloading with CUDA Graphs and Flash Attention enabled by default.
-DCMAKE_CUDA_ARCHITECTURES=121a-realCompiles GB10 device code directly, unlocking architecture-specific Blackwell tensor instructions.
-DGGML_NATIVE=OFF -DGGML_CPU_ARM_ARCH=armv9-a+dotprod+i8mm+bf16+sve+sve2+fp16Enables Armv9.2 Single Instruction, Multiple Data (SIMD), dot-product, and INT8 matrix multiply (i8mm) on the CPUs. Also enables BFloat16, FP16, and Scalable Vector Extension (SVE) or SVE2.
-DGGML_OPENMP=ONEnables OpenMP multi-threading for CPU-side execution.
-DGGML_CPU_KLEIDIAI=ONCompiles Arm KleidiAI quantized matrix microkernels into libggml-cpu.so.

Compile llama.cpp across all 20 Grace CPU cores:

    

        
        
cmake --build build --config Release -j $(nproc)

    

Validate the compiled binaries

Verify that llama-server and llama-bench built cleanly, detect the NVIDIA GPU, link against CUDA libraries, and include Arm KleidiAI CPU symbols:

    

        
        
./build/bin/llama-server --version
./build/bin/llama-bench --list-devices
ldd ./build/bin/llama-server | grep -E "cuda|cublas"
nm -D ./build/bin/libggml-cpu.so | grep -i kleidi | head -n 6

    

The output is similar to:

    

        
        version: 1.1.0-dev (build 12763, commit 5917b39ff)
built with GNU 13.3.0 for Linux aarch64
ggml_cuda_init: found 1 CUDA devices (Total VRAM: 124607 MiB):
  Device 0: NVIDIA GB10, compute capability 12.1, VMM: yes, VRAM: 124607 MiB
Available devices:
  CUDA0: NVIDIA GB10 (124607 MiB, 25274 MiB free)
	libggml-cuda.so.1 => /home/user/hermes-gemma4/llama.cpp/build/bin/libggml-cuda.so.1
	libcudart.so.13 => /usr/local/cuda/targets/sbsa-linux/lib/libcudart.so.13
	libcublas.so.13 => /usr/local/cuda/targets/sbsa-linux/lib/libcublas.so.13
	libcublasLt.so.13 => /usr/local/cuda/targets/sbsa-linux/lib/libcublasLt.so.13
	libcuda.so.1 => /lib/aarch64-linux-gnu/libcuda.so.1
00000000000d01f0 T ggml_backend_cpu_kleidiai_buffer_type
00000000000d7100 T _Z28ggml_kleidiai_select_kernels11cpu_featurePK11ggml_tensor
00000000000d77c4 T _Z32ggml_kleidiai_select_kernels_f3211cpu_feature
00000000000d7630 T _Z33ggml_kleidiai_select_kernels_q4_011cpu_feature
00000000000d7720 T _Z33ggml_kleidiai_select_kernels_q4_k11cpu_feature
00000000000d7740 T _Z33ggml_kleidiai_select_kernels_q8_011cpu_feature

        
    

Confirm that CUDA0: NVIDIA GB10 appears with compute capability 12.1. Ensure that ggml_kleidiai_select_kernels symbols appear in libggml-cpu.so.

What you’ve accomplished and what’s next

You’ve verified your NVIDIA DGX Spark environment, enabled CUDA and Armv9.2 KleidiAI flags in CMake, and compiled llama.cpp from source.

Next, you’ll download Gemma 4 E4B, 26B-A4B Mixture-of-Experts (MoE), and 31B from Hugging Face. You’ll benchmark Blackwell GPU versus CPU performance.