Skip to content
STIRUP

TECHNOLOGY INTELLIGENCE

Understand what's next.

NVIDIA GPUDirect Storage and KvikIO Overview

NVIDIA GPUDirect Storage enables direct data transfer between storage devices and GPU memory, reducing CPU overhead and improving I/O performance through the Magnum IO framework and KvikIO interface.

Share
AI-generated conceptual illustration accompanying: NVIDIA GPUDirect Storage and KvikIO Overview
AI-generated editorial illustration of the article topic; not a photograph, product screenshot or measured result.

Overview of NVIDIA GPUDirect Storage and KvikIO

NVIDIA GPUDirect Storage (GDS) enables a direct data path between supported storage devices and GPU memory, reducing CPU overhead and improving I/O performance. This is achieved through the NVIDIA Magnum IO framework, which facilitates high-speed data transfers without unnecessary data copies. KvikIO, a high-level Python and C++ interface built on top of the cuFile C API, simplifies the use of GDS by providing an easy-to-use API for configuring and managing storage I/O operations. According to NVIDIA Developer, KvikIO allows developers to read data directly into GPU memory, leveraging the accelerated path provided by GDS. A tutorial demonstrated in the post shows how to use the KvikIO Python API to configure storage I/O and confirm that the accelerated path was activated. These tools are designed to help developers optimize data movement in applications that require high-performance storage and GPU memory access.

Prerequisites and Setup for Using KvikIO

Before beginning this tutorial, you will need a Linux system with an NVIDIA GPU and GPUDirect Storage installed. You can inspect the GPU-to-storage topology with the following command: $ nvidia-smi topo -nvme. Step 1 involves setting up NVIDIA KvikIO by creating a Python environment and installing the CUDA 13 build of KvikIO. For example, defaults.set accepts a dictionary to change several settings at once, or a name and value to change one setting: defaults.set({"task_size": 1024**3, "num_threads": 8}) or defaults.set("compat_mode", kvikio.CompatMode.OFF). Next, create the input file once before running the Python example.

Reading Data into GPU Memory with KvikIO

Reading data directly into GPU memory can significantly reduce data transfer overhead in high-performance computing workflows. With NVIDIA GPUDirect Storage and KvikIO, developers can bypass the CPU entirely when moving data from storage to the GPU. The process begins by writing a file using direct I/O, as demonstrated by the dd command, which ensures that data is written directly to storage without intermediate buffering. Next, a CuPy array is allocated in GPU memory to serve as the destination buffer. This buffer is then used by KvikIO's CuFile interface to read the file directly into GPU memory. This approach minimizes latency and maximizes throughput by eliminating unnecessary data copies. The code example shows how to use the read method of the CuFile object to transfer data from the file into the GPU buffer. This technique is particularly useful in applications that require fast data ingestion, such as machine learning and scientific computing.

Verification and Validation of Data Read

Verification and validation of data read into GPU memory using NVIDIA GPUDirect Storage (GDS) with KvikIO involves checking the number of bytes read against the expected size of the GPU buffer. As shown in the code, assert bytes_read == gpu_buffer.nbytes ensures that the entire buffer was filled correctly. To inspect detailed statistics, the command $ CUFILE_STATS_LEVEL=3 python3 -i read_with_kvikio.py runs the script interactively, allowing the gds_stats tool to collect and display performance metrics. A terminal session of cuFile statistics reveals that a 1 GiB read request was divided into 256 operations, each with a default task size of 4 MiB, resulting in a total of 1,024 MiB read. These statistics are attributed to the KvikIO implementation and provide insight into the internal behavior of the read process.

Understanding Data Path and Performance Analysis

Understanding the data path and analyzing performance is essential when reading data into GPU memory using NVIDIA GPUDirect Storage. The process involves multiple control layers, which can be compared by repeating reads with different settings. For example, with the KvikIO default 4 MiB task size, a 1 GiB read results in 256 cuFile requests, highlighting the granularity of data transfer operations. Additionally, when the destination buffer is not registered for storage DMA, cuFile reads into a registered GPU bounce buffer and then copies the data into the final destination. This two-step process can impact performance and should be considered when optimizing data movement. Proper configuration of these layers and understanding their implications are key to achieving efficient data transfers in GPU memory.

Sources and reporting notes

Based on published source material. No independent hands-on testing is claimed.

Read more