Skip to content

Instantly share code, notes, and snippets.

@jmsdnns
Created August 17, 2024 05:01
Show Gist options
  • Save jmsdnns/22a8f7e7609352ae028eaaa4dc96f548 to your computer and use it in GitHub Desktop.
Save jmsdnns/22a8f7e7609352ae028eaaa4dc96f548 to your computer and use it in GitHub Desktop.
Simple demo of how to use Candle with Apple's GPU
use candle_core::{Device, Tensor};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let device = Device::new_metal(0)?;
let a = Tensor::randn(0f32, 1., (2, 3), &device)?;
let b = Tensor::randn(0f32, 1., (3, 4), &device)?;
let c = a.matmul(&b)?;
println!("{c}");
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment