The KAGAMI mark КАГАМИ
kagami.bg/academy · lesson · machine-readable viewUPDATED 2026-10-03
IDENTITY
module
GX10-04-38 · JAX on a GB10-class machine
series
GX10 (local AI server class: NVIDIA GB10, e.g. ASUS Ascent GX10 / DGX Spark)
level
Intermediate
duration
about 1 h
prerequisites
GB10-class machine with DGX OS (Ubuntu, Arm64), Python 3 with venv, pip, an NVIDIA driver of version 580 or newer (required by the JAX CUDA 13 wheels on Linux), basic NumPy
trust_label
UPDATED 2026-10-03 (checked against the official JAX documentation) · NOT TESTED on a GB10 machine · all code is marked "not run"
versions
JAX installed from PyPI with the cuda13 extra; the version is not pinned here, read it with jax.__version__
language
human view: en · bulgarian edition: /academy/gx10/ (same file name)
previous / next
04-37_Single_Cell_RNA.html / 04-39_DGX_Dashboard.html
PURPOSE

Install JAX with NVIDIA GPU support on a GB10-class machine, verify that arrays live on the GPU, and learn the three core transformations: jax.jit (compile with XLA), jax.grad (automatic differentiation) and jax.vmap (automatic batching). Finish with a small neural network trained on synthetic data and a note on GPU memory allocation.

KEY CONCEPTS
COMMANDS / PATHS
CHECKLIST
NEXT MODULE

04-39 · Monitoring a GB10 machine (04-39_DGX_Dashboard.html) · series index: kagami.bg/en/academy/gx10/ · offer: Quick experiment (kagami.bg/stalbata/)

SOURCES
TAGS
gx10nvidia-gb10arm64jaxxlajitautodiffvmappython
UPDATED · 03.10.2026

JAX on GB10: jit, grad and vmap in Practice

JAX is a library for numerical computing that looks like NumPy but has three extra skills: it compiles your functions (jit), it computes derivatives by itself (grad) and it stretches a function written for one example over a whole batch (vmap). Here we put it on a local AI server of the GB10 class and honestly check whether it runs on the graphics card.

⏱ 1 h Intermediate GX10 JAX · XLA · Python Made-up data
JAX in a Python environment🔒 local Packages from PyPI (download)🌐 global
🔄
UPDATED · 03.10.2026 — what changed
The lesson was rebuilt against the official JAX documentation. We removed unverified and misleading claims: "zero-copy access" and "NVLink-C2C at 900 GB/s", "1 PFLOP FP8", "models up to ~120 GB", "XLA knows unified memory", the star-rating table "JAX vs PyTorch", pmap as a main tool, jax[cuda12] as the recommendation and the "EU project scoring" example. We added: installation in a separate virtual environment with jax[cuda13], a check that JAX really sees the graphics card, how to time things honestly (warm-up and block_until_ready), a small neural network on made-up data and a note about memory.
⚠️
What we have not run ourselves
We had no GB10-class machine during the check. The commands were checked against the JAX documentation, but we have not tested them ourselves — which is why there is no "TESTED" label. Especially unchecked is whether the JAX wheels recognise the GB10 graphics card. That is why the most important step in this lesson is the check in step 3: if it fails, do not trust any measurement.

01What you'll learn

02Before you start

💡
Why a separate virtual environment
JAX and its CUDA packages are large and have strict versions. In an environment of their own (venv) they do not damage the system Python, and you can delete the environment with one command.

03Steps

  1. What JAX is

    By its official description JAX is a Python library for accelerator-oriented array computation, designed for high-performance numerical computing and machine learning. It gives you three things:

    • A NumPy-style API in jax.numpy — familiar functions and arrays.
    • Function transformations: jax.jit (compile), jax.grad (derivative), jax.vmap (automatic batching).
    • The same code on a CPU, a GPU and a TPU.

    Compilation goes through XLA — a compiler for linear algebra that fuses many small operations into larger kernels.

  2. Environment and installation

    The JAX documentation recommends the wheels with built-in CUDA libraries (jax[cuda13]) and says that NVIDIA has released CUDA packages for x86_64 and aarch64. So on a GB10 (ARM64) the documented path is this:

    bash · on the machine
    python3 -m venv .venv
    source .venv/bin/activate
    pip install --upgrade pip
    pip install --upgrade "jax[cuda13]"

    Two rules from the documentation: the driver must be ≥ 580 for CUDA 13 on Linux, and the variable LD_LIBRARY_PATH must not be set, because it can override the libraries that come with the package. Wheels for CUDA 12 are offered too, but JAX recommends moving to CUDA 13.

    ⚠️
    The command has not been run on GB10
    The JAX documentation lists "Linux, aarch64 + NVIDIA GPU" as a supported platform, but we have not checked whether the GB10 graphics card in particular is recognised. The Isaac Lab documentation has an older note saying JAX has CUDA wheels only for x86_64 — it disagrees with the current JAX documentation. So do not guess: run the check in the next step.
  3. Check whether JAX sees the graphics card

    bash
    python -c "import jax; print(jax.devices()); print(jax.__version__)"

    You expect a list with a device of the CUDA type (for example CudaDevice(id=0)). If you see only CpuDevice, JAX is running on the CPU only — it is not broken, but it will not speed anything up on the graphics card, and all the measurements below are for the CPU. In that case check the driver version and look at NVIDIA's JAX-Toolbox containers (in the sources).

  4. jit — compile the function

    jax.jit compiles the function on the first call and then repeats the ready code. The first call is slow (it compiles), the following ones are fast. JAX sends the work to the graphics card asynchronously, so when timing you must wait for the result with block_until_ready(), otherwise you only measure the time to send it.

    python · not run
    import time
    import jax
    import jax.numpy as jnp
    
    def f(x):
        return jnp.sum(x ** 2 + jnp.sin(x))
    
    f_jit = jax.jit(f)
    x = jnp.ones((10_000_000,))
    
    f_jit(x).block_until_ready()          # warm-up: the compilation happens here
    
    t = time.perf_counter()
    for _ in range(100):
        f_jit(x).block_until_ready()
    print("with jit:", time.perf_counter() - t)
    
    t = time.perf_counter()
    for _ in range(100):
        f(x).block_until_ready()
    print("without jit:", time.perf_counter() - t)

    The result depends on the machine — we promise no values. The important habit is: one warm-up, then measure with block_until_ready().

  5. grad — a derivative without manual work

    jax.grad(f) returns a new function that computes the gradient of f with respect to its first argument. This lets you minimise a function with gradient descent.

    python · not run
    import jax
    import jax.numpy as jnp
    
    g = jax.grad(lambda x: x ** 3)
    print(g(2.0))      # 12.0, because the derivative is 3·x²
    
    def mse(params, x, y):
        return jnp.mean((params["w"] * x + params["b"] - y) ** 2)
    
    x = jnp.arange(5.0)
    y = 2.0 * x + 1.0                       # made-up data: w=2, b=1
    params = {"w": 0.0, "b": 0.0}
    grad_fn = jax.jit(jax.grad(mse))
    
    for _ in range(500):
        grads = grad_fn(params, x, y)
        params = jax.tree.map(lambda p, d: p - 0.05 * d, params, grads)
    
    print(params)      # close to w=2, b=1

    The parameters are a dictionary — JAX works with such "trees", and jax.tree.map applies a function to every leaf.

  6. vmap — from one example to a whole batch

    You write the function for one example, and jax.vmap makes it work over a batch, with no Python loop.

    python · not run
    import jax
    import jax.numpy as jnp
    
    def dot(a, b):
        return jnp.dot(a, b)
    
    batched_dot = jax.vmap(dot)
    
    A = jnp.ones((1000, 512))
    B = jnp.ones((1000, 512))
    print(batched_dot(A, B).shape)          # (1000,)
    
    fast = jax.jit(jax.vmap(dot))           # transformations combine
    print(fast(A, B).shape)
  7. A small neural network with JAX only

    We build a network with one hidden layer and train it on made-up data: the class is 1 when the sum of the first two values is positive. This way no outside datasets are needed.

    python · not run
    import jax
    import jax.numpy as jnp
    
    def init_params(key, sizes):
        keys = jax.random.split(key, len(sizes) - 1)
        return [
            (jax.random.normal(k, (m, n)) * jnp.sqrt(2.0 / m), jnp.zeros(n))
            for k, m, n in zip(keys, sizes[:-1], sizes[1:])
        ]
    
    def predict(params, x):
        for W, b in params[:-1]:
            x = jax.nn.relu(x @ W + b)
        W, b = params[-1]
        return x @ W + b
    
    def loss(params, x, y):
        logp = jax.nn.log_softmax(predict(params, x))
        return -jnp.mean(jnp.take_along_axis(logp, y[:, None], axis=1))
    
    @jax.jit
    def step(params, x, y):
        l, grads = jax.value_and_grad(loss)(params, x, y)
        params = jax.tree.map(lambda p, d: p - 0.1 * d, params, grads)
        return params, l
    
    key = jax.random.PRNGKey(0)
    x = jax.random.normal(key, (2000, 20))
    y = (x[:, 0] + x[:, 1] > 0).astype(jnp.int32)
    
    params = init_params(jax.random.PRNGKey(1), [20, 64, 2])
    for i in range(200):
        params, l = step(params, x, y)
        if i % 50 == 0:
            print(i, float(l))
    
    acc = jnp.mean(jnp.argmax(predict(params, x), axis=1) == y)
    print("accuracy on the training data:", float(acc))

    You expect the loss to fall and the accuracy to rise. The exact numbers will differ. Note that step is the whole training step — computing the loss, the gradient and the update — and jit compiles it in one go.

  8. The graphics card's memory

    By the JAX documentation (the "GPU memory allocation" section) JAX by default preallocates a large share of the graphics card's memory. You can turn that off with an environment variable, before you import jax:

    python
    import os
    os.environ["XLA_PYTHON_CLIENT_PREALLOCATE"] = "false"
    
    import jax

    On GB10 the CPU and the GPU share the same 128 GB, so it makes sense for JAX not to grab a large share in advance. ⚠️ We have not measured exactly how JAX behaves on this shared memory; watch it with nvidia-smi and free -h.

04Check

Quiz

1. jax.devices() returns only CpuDevice. What does it mean?

2. Why do you call block_until_ready() when timing speed?

3. What does jax.grad(f) return?

4. What is jax.vmap for?

05What's next

06Sources

  1. JAX: installation 🔒 local — supported platforms, wheels for NVIDIA GPUs, driver ≥ 580 for CUDA 13, LD_LIBRARY_PATH.
  2. JAX 101: grad and vmap · JAX 201: jit — what the transformations do.
  3. JAX: GPU memory allocation — preallocation and the environment variables.
  4. Isaac Lab: installation ("DGX Spark" section) — the older note about JAX on aarch64.
  5. NVIDIA JAX-Toolbox — NVIDIA containers with JAX.
  6. NVIDIA DGX Spark: known issues — shared memory, "Memory-Usage: Not Supported".