- Added Python samples for CUDA Python 1.0 release - Renamed top-level `Samples` directory to `cpp` to accommodate Python samples.
Sample: System Information Query (Python)
Description
This sample demonstrates how to inspect the CUDA driver, NVML, and every
installed GPU through the
cuda.core.system
module.
cuda.core.system wraps the NVIDIA Management Library (NVML) and can be
imported without CUDA being installed or initialized, so it is useful as a
lightweight pre-flight check before any CUDA context is created. The script
prints driver and NVML versions, the current process name, per-device
metadata (name, compute capability, architecture, memory, PCI info,
temperature, performance state), and, on multi-GPU systems, the topology
and peer-to-peer capabilities between each pair of devices.
What You'll Learn
- Querying CUDA driver and NVML versions with
cuda.core.system - Enumerating GPUs without creating a CUDA context
- Reading per-device metadata exposed by NVML (name, UUID, memory usage, temperature, performance state)
- Inspecting GPU-to-GPU topology and peer-to-peer (P2P) capabilities
Key Libraries
cuda.core.system- Python wrapper around NVML
Key APIs
From cuda.core.system:
get_driver_version(),get_driver_version_full(),get_driver_branch()- CUDA driver version tuple and branch stringget_nvml_version()- NVML library versionget_num_devices()- number of GPUs visible to NVMLget_process_name(pid)- process name for a given PIDDevice(index=...)- NVML-backed device handle (no CUDA context required)name,uuid,cuda_compute_capability,arch,brandmemory_info(total,used,free)pci_info(domain,bus,device,bus_id)temperature.sensor(TemperatureSensors.TEMPERATURE_GPU)performance_state
get_topology_common_ancestor(dev0, dev1)-GpuTopologyLevelbetween two devicesget_p2p_status(dev0, dev1, GpuP2PCapsIndex.P2P_CAPS_INDEX_READ)- peer-access capability between two devices
Import stable symbols from the top-level cuda.core package (not cuda.core.experimental).
Requirements
- NVIDIA Graphics Card with CUDA support
- CUDA Drivers installed on your system
- CUDA Toolkit installed on your system
- Python 3.12 or newer
Hardware
- One or more NVIDIA GPUs
- Driver compatible with
cuda-python13.x
Software
- CUDA Toolkit 13.0 or newer (matches
cuda-python13.x) - Python 3.10 or newer
cuda-python(>=13.0.0)cuda-core(>=0.6.0)
Installation
Install the required packages from requirements.txt:
cd /path/to/cuda-samples/python/1_GettingStarted/systemInfo
pip install -r requirements.txt
The requirements.txt installs:
cuda-python(>=13.0.0)cuda-core(>=0.6.0)
How to Run
Basic usage
cd cuda-samples/python/1_GettingStarted/systemInfo
python systemInfo.py
Skip topology queries
Useful on machines with only one GPU or to shorten the output:
python systemInfo.py --no-topology
Expected Output
Output varies with your hardware. On a machine with two GPUs you should see something like:
======================================================================
Driver / NVML
======================================================================
CUDA driver version: 13.2
CUDA driver version (full): (13, 2, 0)
NVML version: (13, 595, 58, 3)
Driver branch: r595_88
Current process: /usr/bin/python
======================================================================
Devices detected: 2
======================================================================
-- Device 0 --
Name: <Your GPU Name>
UUID: ...
Compute capability: 8.9
Architecture: ADA
Brand: BRAND_GEFORCE
Memory: total=23.99 GiB, used=960.00 KiB, free=23.52 GiB
PCI: domain=0000 bus=41 device=00 id=00000000:41:00.0
Temperature (GPU sensor): 47 C
Performance state: <Pstates.PSTATE_8: 8>
...
======================================================================
GPU topology and peer-to-peer
======================================================================
Device 0 <-> Device 1: topology=TOPOLOGY_HOSTBRIDGE, p2p_read=..., p2p_write=...
Done
Note: Device names, compute capability, temperatures, and topology details will vary based on your GPUs and system.
Files
systemInfo.py- Python implementation usingcuda.core.systemREADME.md- This filerequirements.txt- Sample dependencies