MCPcopy Create free account
hub / github.com/evilsocket/cake / get_device

Function get_device

cake-core/src/models/sd/util.rs:66–86  ·  view source on GitHub ↗
(cpu: bool)

Source from the content-addressed store, hash-verified

64}
65
66pub fn get_device(cpu: bool) -> Result<Device> {
67 if cpu {
68 Ok(Device::Cpu)
69 } else if cuda_is_available() {
70 Ok(Device::new_cuda(0)?)
71 } else if metal_is_available() {
72 Ok(Device::new_metal(0)?)
73 } else {
74 #[cfg(all(target_os = "macos", target_arch = "aarch64"))]
75 {
76 println!(
77 "Running on CPU, to run on GPU(metal), build this example with `--features metal`"
78 );
79 }
80 #[cfg(not(all(target_os = "macos", target_arch = "aarch64")))]
81 {
82 println!("Running on CPU, to run on GPU, build this example with `--features cuda`");
83 }
84 Ok(Device::Cpu)
85 }
86}
87
88pub fn get_sd_config(ctx: &Context) -> Result<StableDiffusionConfig> {
89 let height = ctx.args.sd_args.height;

Calls

no outgoing calls