Burn Ride

Begin Your Journey

  1. Burn Book
  2. Documentation
01

Install Rust

The first step is to install Rust. Refer to the Rust book's installation page.

Down arrow
02

Create a Rust Application

  1. Open your preferred terminal or command prompt.
  2. Use Cargo, Rust's package manager, to create a new Burn application in a specific directory.
  3. Change your current directory to the newly created project
03Space Ship

Add Burn Dependency and Choose Backend

  1. Cargo simplifies the process of including external libraries. The following command adds the main dependency and specify the [wgpu] backend
04Burn

Start Developing with Burn

  1. With Burn successfully installed, you're now ready to start developing your deep learning projects using this powerful framework.
05

Basic Example

Now open [src/main.rs] and replace its content with:

use burn::tensor::{Tensor, backend::Backend};

fn computation<B: Backend>() {
    // Create the device where to do the computation
    let device = Default::default();

    let tensor1: Tensor<B, 2> = Tensor::from_floats([[2., 3.], [4., 5.]], &device);
    let tensor2 = Tensor::ones_like(&tensor1);

    // Print the element-wise addition of the two tensors.
    println!("{:}", tensor1 + tensor2);
}

fn main() {
    computation::<burn::backend::Wgpu>();
}

And then:

You should now see the result of the addition:

Tensor {
  data: [[3.0, 4.0], [5.0, 6.0]],
  shape: [2, 2],
  device: BestAvailable,
  backend: "fusion<jit<wgpu<wgsl>>>",
  kind: "Float",
  dtype: "f32",
}

While this example is somewhat trivial, the basic workflow section of the Burn Book will walk you through a much more relevant example for deep learning applications.

Stay connected

Join our community! We'd love to keep you in the loop with our newsletter.

unsubscribed