NIXL Python API

1.0.0 · active · verified Mon Apr 13

NIXL is a Python API meta-package designed to simplify the installation and usage of NIXL's core functionalities across various CUDA versions. It automatically detects the system's CUDA environment and installs the appropriate `nixl-cudaXXX` sub-package, providing a unified `nixl.core` interface for tensor operations, device management, and more. Current version is 1.0.0, with releases tied to new CUDA variant support.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates initializing the NIXL environment, retrieving device information, and performing basic tensor operations on the CPU. It also includes a commented-out section showing how to attempt a GPU tensor creation, highlighting the requirement for a functional CUDA environment and a compatible `nixl-cudaXXX` backend.

import nixl.core as nixl

# Initialize NIXL (e.g., set up a simple logger)
nixl.init()

# Get device information
device_info = nixl.get_device_info()
print(f"Device Info: {device_info}")

# Basic tensor creation and manipulation on CPU
tensor_a = nixl.Tensor([1, 2, 3], dtype=nixl.DType.I32, device=nixl.Device.CPU)
print(f"Tensor A: {tensor_a}")

tensor_b = nixl.Tensor([4, 5, 6], dtype=nixl.DType.I32, device=nixl.Device.CPU)
tensor_c = tensor_a + tensor_b
print(f"Tensor C (A + B): {tensor_c}")

# Example of attempting GPU operation (requires CUDA backend)
# try:
#     tensor_gpu = nixl.Tensor([7, 8, 9], dtype=nixl.DType.F32, device=nixl.Device.GPU)
#     print(f"Tensor on GPU: {tensor_gpu}")
# except RuntimeError as e:
#     print(f"Could not create GPU tensor: {e} (Is CUDA device available and correct nixl-cudaXXX installed?)")

view raw JSON →