coreylowman / cudarc

Safe rust wrapper around CUDA toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`CudaDevice::new` panics when no GPU is connected

g33kex opened this issue · comments

When no GPU is connected, the following code panics:

use cudarc::driver::CudaDevice;
fn main() {
    let dev0 = CudaDevice::new(0);
}
thread 'main' panicked at /home/g33kex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cudarc-0.10.0/src/driver/safe/core.rs:51:24:
called `Result::unwrap()` on an `Err` value: DriverError(CUDA_ERROR_NO_DEVICE, "no CUDA-capable device is detected")

I'm using cudarc version 0.10.0 on a machine with no CUDA-capable device connected.

The function should not panic and return a proper DriverError value.