(cpu: bool)
| 64 | } |
| 65 | |
| 66 | pub 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 | |
| 88 | pub fn get_sd_config(ctx: &Context) -> Result<StableDiffusionConfig> { |
| 89 | let height = ctx.args.sd_args.height; |
no outgoing calls