mirror of
https://github.com/huggingface/candle.git
synced 2025-06-16 02:38:10 +00:00

- Moved around book from `examples` to `candle-book` proper (overlapping the book and the lib structures)
18 lines
419 B
Rust
18 lines
419 B
Rust
pub mod coco_classes;
|
|
pub mod imagenet;
|
|
pub mod object_detection;
|
|
|
|
use candle::{Device, Result, Tensor};
|
|
|
|
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)
|
|
}
|
|
}
|