fn device()

in issue-bot/src/embeddings/local.rs [61:84]


fn device() -> Result<Device, EmbeddingError> {
    if cuda_is_available() {
        debug!("using CUDA");
        Ok(Device::new_cuda(0)?)
    } else if metal_is_available() {
        debug!("using metal");
        Ok(Device::new_metal(0)?)
    } else {
        #[cfg(all(target_os = "macos", target_arch = "aarch64"))]
        {
            warn!("Running on CPU, to run on GPU(metal), use the `-metal` binary");
        }
        #[cfg(not(all(target_os = "macos", target_arch = "aarch64")))]
        {
            warn!("Running on CPU, to run on GPU, use the `-cuda` binary");
        }
        if has_mkl() {
            debug!("using MKL");
        } else {
            debug!("using CPU");
        }
        Ok(Device::Cpu)
    }
}