Skip to content

willxxy/rust-nn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-nn

Exploration of deep learning through rust, more specifically through tracel-ai's burn deep learning framework.

After some experimentation, found that tch-rs may be better for now (more stable). So will switch the focus to that.

Tested on macOS Sonoma version 14.5, Apple M2 Max, Macbook Pro and rustc version 1.79.0.

Usage

  1. git clone https://github.com/willxxy/rust-nn.git
  2. cd rust-nn
  3. cargo run to run all examples. Run cargo run -- -e mm for matrix multiplication. The other examples are included in the section.

Note: Make sure to have rust installed.

Current Examples

All examples are under ./src/examples

Current examples include:

  1. create_tensors.rs (create) - Simple tensor creation and addition provided in the burn book tutorial.

  2. gpu_vs_cpu_add.rs (add) - Testing GPU vs CPU performance times for 1000x1000 matrix addition for 100 iterations.

  3. gpu_vs_cpu_mm.rs (mm) - Testing GPU vs CPU performance times for 1000x1000 matrix multiplication for 100 iterations.

Note: The matrices created for GPU is done through burn and the matrices created for CPU is done through ndarray. Additionally, the .matmul() operation for burn and .dot() operation for ndarray are a bit different so this doesn't make it a completely fair comparison...

GPU vs CPU Performance

Note that there is no warmup for the GPU.

Addition

Device Duration per Iteration Duration for 100 Iterations
GPU 15.457µs 1.545708ms
CPU 26.682145ms 2.668214584s

Matrix Multiplication

Device Duration per Iteration Duration for 100 Iterations
GPU 321.857µs 32.18575ms
CPU 2.09207541s 209.207541041s

TODO

  • Switch to tch-rs
  • Create MNIST tutorial.

About

Exploration of deep learning through rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages