Skip to main content

runtime_version

Function runtime_version 

Source
pub fn runtime_version() -> Result<CudaVersion>
Expand description

CUDA Runtime version linked via libcudart.

Examples found in repository?
examples/device_query.rs (line 20)
18fn main() -> Result<(), Box<dyn std::error::Error>> {
19    println!("CUDA driver version: {}", driver_version()?);
20    println!("CUDA runtime version: {}", runtime_version()?);
21
22    let devices = Device::all()?;
23    println!("found {} CUDA device(s)", devices.len());
24
25    for dev in &devices {
26        // Switch current-thread device before querying properties:
27        // `device_properties` reads via `cudaGetDeviceProperties`, which
28        // is keyed off the ordinal we pass — but other Runtime calls
29        // (memory queries, kernel launches) operate on the current
30        // device, so it's good practice to bind first.
31        dev.set_current()?;
32        let props = device_properties(dev)?;
33        let (cc_major, cc_minor) = dev.compute_capability()?;
34        let sm_count = dev.multiprocessor_count()?;
35        let warp = dev.warp_size()?;
36
37        let gib = (props.total_global_memory_bytes as f64) / (1024.0 * 1024.0 * 1024.0);
38        println!(
39            "  [{}] {:30}  cc {}.{}  {} SMs  warp {}  {:.2} GiB",
40            dev.ordinal(),
41            props.name,
42            cc_major,
43            cc_minor,
44            sm_count,
45            warp,
46            gib,
47        );
48    }
49
50    // Make sure all pending work on every device (none here) is done.
51    device_synchronize()?;
52    println!("OK");
53    Ok(())
54}