DEV Community

Cover image for Understanding the GPU Software Stack: From Your Application to the GPU Hardware
Muhammad Zubair Bin Akbar
Muhammad Zubair Bin Akbar

Posted on Originally published at hpcpulse.substack.com

Understanding the GPU Software Stack: From Your Application to the GPU Hardware

When people start learning about GPU computing, they usually come across names like CUDA, ROCm, HIP, cuBLAS, rocBLAS, HSA Runtime, and GPU drivers.

All these technologies are important, but there is one question that often gets overlooked:

When you run an application that uses a GPU, how does your application actually communicate with the physical GPU?

Does PyTorch talk directly to the GPU? Does CUDA control everything? Where do libraries and drivers fit into the picture? And why does AMD have something called HSA Runtime?

These are all parts of the same bigger picture: the GPU software stack.

In this article, let's break down this architecture layer by layer, starting with the application and working our way down to the physical GPU hardware.

We will use NVIDIA CUDA and AMD ROCm as examples, keeping things as simple as possible.

First, what is the GPU software stack?

Think about your computer for a moment.

When you open an application, it doesn't normally communicate directly with your processor or other hardware. It relies on the operating system, drivers, and other software components to make everything work.

GPU computing follows a similar concept.

A GPU application needs several software components to work together before its instructions can be executed by the physical GPU.

These components form what we call the GPU software stack.

A simplified view looks like this:

Application

PyTorch, TensorFlow, scientific applications, custom GPU programs

↓

GPU Libraries

cuBLAS, cuDNN, rocBLAS, MIOpen

↓

GPU Runtime

CUDA Runtime, HIP Runtime

↓

Lower-level GPU Interfaces and Runtime

CUDA Driver API, HSA Runtime (ROCr)

↓

GPU Kernel Driver

NVIDIA GPU driver, AMD amdgpu and KFD

↓

GPU Hardware

NVIDIA GPUs, AMD Instinct GPUs

Each layer has a different responsibility. Some make programming easier, others manage execution, and others provide the interface to the physical hardware.

Let's understand what each one does.

1. Application: Where everything starts

The application is the software that actually needs GPU computing power.

For example, imagine someone training an AI model using PyTorch.

They write Python code, load their dataset, define a neural network, and tell PyTorch to use the GPU.

Other examples include TensorFlow applications, scientific simulations, engineering applications, and custom GPU programs written in C++.

At this stage, the developer is mainly concerned with what they want to calculate, rather than how the GPU performs the calculation internally.

For example, they might request a matrix multiplication, which is one of the most common operations in AI workloads.

But how does the application know how to perform that operation efficiently on the GPU?

This is where the next layer comes in.

2. GPU Libraries: Ready-made tools for complex calculations

Imagine you need to perform a mathematical operation that involves millions of calculations.

You could write all the code yourself, but that would take considerable time and effort.

Instead, you can use an existing library that already contains optimised functions for performing these operations.

That is exactly what GPU libraries provide.

They contain pre written, optimised functions that applications can use for common computational tasks.

For example, consider matrix multiplication.

Instead of developing a complete implementation from scratch, an application can use an existing GPU library to perform the operation efficiently.

Here are some examples:

NVIDIA:

  • cuBLAS: Optimised mathematical operations, including matrix multiplication.
  • cuDNN: GPU accelerated operations commonly used in deep learning.
  • cuFFT: Fast Fourier Transform operations.

AMD:

  • rocBLAS: Optimised mathematical operations, including matrix multiplication.
  • MIOpen: Deep learning primitives and operations.
  • rocFFT: Fast Fourier Transform operations.

You might notice that NVIDIA and AMD offer libraries with similar purposes.

They are designed to solve similar computational problems, although their implementations and supported hardware differ.

One important point: these libraries do not replace the application. They provide specialised functionality that applications and frameworks can call when needed.

Think of them as a collection of ready made tools that save developers from reinventing the wheel.

3. GPU Runtime: Managing communication and execution

Now we reach one of the most important parts of the GPU software stack.

The runtime provides an interface that allows applications and libraries to interact with the GPU computing environment.

It handles many of the operations required to get work ready for the GPU.

For example:

  • Allocating memory on the GPU.
  • Copying data between CPU and GPU memory.
  • Launching GPU kernels.
  • Managing execution streams.
  • Handling synchronisation between operations.

But what exactly is a GPU kernel?

A kernel is simply a function that is executed on the GPU.

For example, imagine you want to add two large arrays containing millions of numbers.

Instead of asking the CPU to perform every addition one by one, a GPU kernel can distribute the work across many GPU processing elements.

The runtime helps organise and launch that work.

Now let's look at how NVIDIA and AMD approach this.

NVIDIA: CUDA Runtime

NVIDIA provides the CUDA Runtime API, commonly known as the CUDA Runtime.

It gives developers a relatively straightforward way to manage GPU memory, launch kernels, and interact with CUDA enabled GPUs.

AMD: HIP Runtime

AMD provides HIP, which stands for Heterogeneous computing Interface for Portability.

HIP offers a programming interface similar to CUDA and allows developers to write GPU applications for AMD hardware.

It is also useful when porting applications originally developed for CUDA.

One important distinction: HIP is not the entire ROCm platform. It is one of the programming interfaces available within the broader ROCm ecosystem.

Think of the runtime as the coordinator that helps applications organise and submit work for GPU execution.

4. Lower level interfaces: CUDA Driver API and HSA Runtime

This is where beginners often start getting confused, particularly when exploring AMD ROCm.

Although NVIDIA and AMD follow similar overall concepts, their underlying software architectures are not identical.

Let's look at them separately.

NVIDIA: CUDA Driver API

Underneath the CUDA Runtime, NVIDIA provides another interface called the CUDA Driver API.

The CUDA Driver API offers lower level control over GPU operations.

It handles things such as GPU contexts, loading GPU code, managing modules, and launching kernels.

You might wonder why NVIDIA needs two interfaces.

The reason is flexibility.

The CUDA Runtime provides a more convenient programming interface, while the Driver API gives developers and software frameworks more direct control over GPU resources and execution.

Most developers do not need to interact with the Driver API directly because the CUDA Runtime handles many of these details.

However, applications can also use the Driver API directly.

AMD: HSA Runtime (ROCr)

AMD takes a different approach.

Within the ROCm ecosystem, you will come across something called the HSA Runtime, commonly known as ROCr.

But what does HSA mean?

HSA stands for Heterogeneous System Architecture.

The idea behind HSA is to provide an architecture and programming model that supports different types of processors, particularly CPUs and GPUs, working together.

The ROCr Runtime provides lower level interfaces for managing GPU devices, memory, execution queues, and submitting work for execution.

In simple terms, HIP provides a convenient programming interface, while ROCr provides lower level runtime functionality for interacting with the GPU execution environment.

This is why you often see HSA and ROCr mentioned when exploring the AMD ROCm software stack.

The important thing to remember is that CUDA Driver API and HSA Runtime are not identical technologies. They serve related roles in their respective ecosystems, but their designs and responsibilities differ.

5. GPU Driver: Connecting software to hardware

Now we move closer to the physical GPU.

Just like your network card, storage controller, or other hardware devices, a GPU needs a driver so that the operating system can interact with it.

The GPU driver provides the necessary operating system-level support for GPU operations.

It manages hardware resources and exposes interfaces that the GPU software environment can use.

Let's look at both platforms.

NVIDIA GPU Driver

NVIDIA provides its GPU driver software to support communication between the operating system and NVIDIA GPUs.

The driver includes kernel level components and user space components that work together to support GPU computing.

The CUDA Driver API is part of this software environment.

AMD amdgpu Driver

On Linux, AMD uses the amdgpu kernel driver to provide operating system support for its GPUs.

There is also an important component called the Kernel Fusion Driver, or KFD.

KFD provides the kernel level interface used by the HSA Runtime for GPU compute operations.

This is an important distinction:

ROCr is a user space runtime, whereas amdgpu and KFD provide kernel level support.

Think of the GPU driver as the bridge between the software environment and the physical hardware.

Without the appropriate driver support, the GPU software stack cannot properly interact with the device.

6. GPU Hardware: Where the actual computation happens

Finally, we reach the physical GPU.

Everything we have discussed so far exists to make it possible for applications to use the GPU hardware.

A GPU contains a large number of processing elements designed to execute many operations in parallel.

It also has its own memory, commonly called VRAM, where data required for GPU workloads can be stored.

For example, when training an AI model:

The model parameters and input data need to be made available to the GPU.

The GPU executes the mathematical operations required by the model.

The resulting calculations are then made available to the application.

Examples of GPU hardware include NVIDIA H100, H200 and B200 GPUs, as well as AMD Instinct MI300X and MI350 GPUs.

At this point, all the software layers above have helped prepare and submit the work that the GPU hardware needs to execute.

Putting everything together: What happens when you run a GPU application?

Let's bring everything together using a practical example.

Imagine you have a PyTorch application that performs matrix multiplication using an NVIDIA GPU.

What happens behind the scenes?

First, you run your PyTorch application and request a matrix multiplication.

Second, PyTorch uses an appropriate GPU library, such as cuBLAS, to perform the mathematical operation.

Third, the CUDA Runtime manages the necessary memory operations and GPU kernel launch.

Fourth, the CUDA Driver API provides the lower level interface for GPU execution.

Fifth, the NVIDIA GPU driver provides the operating system and hardware interface.

Finally, the GPU executes the matrix multiplication and produces the results.

The results eventually become available to your application.

The same general concept applies to AMD GPUs, but the software components are different.

For example, an AMD based application might use PyTorch with ROCm, rocBLAS, HIP Runtime, ROCr Runtime, and the AMD GPU driver.

There is one important detail worth remembering: this is a simplified conceptual flow, not a strict sequence of separate components. Applications can interact with different layers directly, and libraries may call runtime APIs themselves.

The main idea is that the application does not normally need to manage every hardware level detail. The software stack takes care of much of that complexity.

Why should HPC engineers understand these layers?

Understanding the GPU software stack is not only useful for application developers.

It is particularly important for HPC engineers and system administrators who deploy, maintain, and troubleshoot GPU enabled infrastructure.

Imagine a few common situations.

Your application cannot detect the GPU.

The problem could be related to the application, framework installation, GPU visibility, or driver configuration.

A CUDA or HIP application fails to start.

You may need to investigate missing runtime libraries, incompatible dependencies, or driver compatibility.

The GPU is detected, but the application fails during execution.

The issue might be related to the runtime, lower level execution environment, or GPU driver.

Your GPU is available, but performance is lower than expected.

The problem could involve inefficient GPU kernels, library versions, memory transfers, or hardware utilisation.

Understanding the different layers gives you a much better starting point when investigating these issues.

It also helps explain why installing a GPU driver alone does not necessarily give you a complete GPU computing environment.

You may still need the appropriate runtime, libraries, compiler toolchain, and application dependencies.

Final thoughts

GPU computing is often introduced through programming frameworks such as PyTorch, TensorFlow, CUDA, and ROCm.

However, there is an entire software architecture underneath these technologies that makes GPU acceleration possible.

Once you understand how applications interact with libraries, runtimes, drivers, and eventually the physical GPU, many previously confusing concepts start to make sense.

You don't need to understand every internal detail straight away.

Start by understanding what each layer does and why it exists.

That foundation will make it much easier to explore CUDA, ROCm, GPU programming, and modern AI infrastructure in greater depth.

Because understanding GPU computing is not just about knowing what a GPU can do. It is also about understanding all the software that makes it possible.


Top comments (1)

Collapse
 
userxnom profile image
Abdullah Naseer •

The layer-by-layer map is clear, and the part I'd underline is your note that the flow is "a simplified conceptual flow, not a strict sequence" — that's where the debugging value actually lives, because the layer that breaks is rarely the one the error message names.

One concrete case your troubleshooting section could use: PyTorch reporting CUDA as unavailable while nvidia-smi happily shows the GPU. That split points straight at the runtime/driver boundary — nvidia-smi shows the driver, while torch.version.cuda shows the CUDA runtime the PyTorch build expects, and if the driver is older than that runtime, the GPU is visible and unusable at the same time. Comparing those two version numbers is the fastest way to tell whether you're looking at a driver problem or a framework-install problem, before touching the code at all.

A sharper version of your diagnostic list might be one command per layer — nvidia-smi for the driver, torch.cuda.is_available() for the runtime, a tiny cuBLAS matmul for the library layer — so a reader can find the broken layer in about a minute. Have you run into a case where the GPU was detected everywhere except inside the container or venv, where the break was in a different layer than the error suggested?