NVIDIA cuFile (CUDA 12)

1.14.1.1 · active · verified Sun Mar 29

nvidia-cufile-cu12 is a Python distribution package that provides the underlying NVIDIA cuFile GPUDirect Storage (GDS) libraries specifically compiled for CUDA 12. These libraries enable a direct data path for Direct Memory Access (DMA) transfers between GPU memory and storage, bypassing the CPU to increase bandwidth and decrease latency. It is generally consumed as a dependency by higher-level Python libraries like `cuda-python` (which exposes `cuda.bindings.cufile`) or other GPU-accelerated data science tools. The current version is 1.14.1.1, with a release cadence tied to CUDA Toolkit updates.

Warnings

Install

Imports

Quickstart

This conceptual quickstart demonstrates how to access the `cufile` module through `cuda.bindings` after installing `cuda-python` and `nvidia-cufile-cu12`. Direct, runnable examples of cuFile operations are highly dependent on specific hardware (NVIDIA GPU), a GPUDirect Storage enabled filesystem, and a properly configured NVIDIA driver, making a universally runnable snippet impractical without such a setup. It outlines the typical high-level steps for interacting with the cuFile API in Python.

# The 'nvidia-cufile-cu12' package provides the underlying C/C++ cuFile libraries.
# To interact with cuFile from Python, you typically use the 'cuda-python' package.
# Install cuda-python: pip install cuda-python numpy

import numpy as np
from cuda.bindings import cufile, driver

# NOTE: This quickstart is conceptual and requires a system with GPUDirect Storage
# enabled, a compatible filesystem, and appropriate NVIDIA hardware/driver setup.
# A simple 'hello world' is not feasible without such infrastructure.

def conceptual_cufile_usage():
    print("Initializing CUDA driver and cuFile (conceptual)...")
    try:
        # Initialize CUDA driver (required for cuFile operations)
        driver.cuInit(0)
        
        # Open cuFile driver
        cufile.driver_open()
        
        # --- Example: Hypothetical buffered read/write setup ---
        # In a real scenario, you'd perform operations like:
        # 1. Allocate GPU memory (e.g., using CuPy or PyTorch on device)
        # 2. Register the buffer with cuFile (cufile.buf_register)
        # 3. Open a file for GPUDirect Storage (e.g., POSIX open on a supported filesystem)
        # 4. Register the file handle with cuFile (cufile.handle_register)
        # 5. Perform I/O operations (cufile.read, cufile.write)
        # 6. Deregister handles and buffers (cufile.handle_deregister, cufile.buf_deregister)

        print("cuFile driver opened successfully. Real I/O requires extensive setup.")
        print("Please refer to NVIDIA GPUDirect Storage documentation for full usage.")
        
    except Exception as e:
        print(f"An error occurred during conceptual cuFile initialization: {e}")
    finally:
        try:
            # Close cuFile driver
            cufile.driver_close()
            print("cuFile driver closed (conceptual).")
        except Exception as e:
            print(f"Error closing cuFile driver: {e}")

if __name__ == "__main__":
    conceptual_cufile_usage()

view raw JSON →