Files
candle/candle-examples/src/lib.rs
2023-07-15 08:25:15 +01:00

14 lines
344 B
Rust

use candle::{Device, Result};
pub fn device(cpu: bool) -> Result<Device> {
if cpu {
Ok(Device::Cpu)
} else {
let device = Device::cuda_if_available(0)?;
if !device.is_cuda() {
println!("Running on CPU, to run on GPU, build this example with `--features cuda`");
}
Ok(device)
}
}