Rust based Cross-GPU Machine Learning

Related tags

Machine learning hal
Overview

HAL : Hyper Adaptive Learning

Rust based Cross-GPU Machine Learning. Build Status

Why Rust?

This project is for those that miss strongly typed compiled languages. Rust was chosen specifically because of this Furthermore, we can offer fine grained control of your operations. This means being able to grab dimensions of tensors at any stage, none of that unknown shape nonsense. We can also micro-control steps. An example of this working with each individual forward timesteps on say an LSTM. Usually these are controlled by inner loops [Theano/Tensorflow, etc].

Features

  • Multi GPU [model based] support
  • OpenCL + CUDA + Parallel CPU support
  • LSTM's with internal RTRL [Work in Progress]
  • RNN's [Work in Progress]
  • Perceptrons, AutoEncoders, ConvNets**[TODO]**
  • Optimizers: [SGD, Adam, AdaGrad**[TODO]**]
  • Activations: [Linear, Sigmoid, Tanh, ReLU, LReLU, Softmax]
  • Initializations: [Lecun Uniform, Glorot Normal, Glorot Uniform, Normal, Uniform]
  • Data Gatherers: [SinSource, MNIST**[In Progress], CIFAR10[TODO]**]
  • Loss Functions: [MSE, L2, Cross-Entropy]
  • OpenGL based plotting and image loading, see here for more info
  • Multi GPU [horizontal] support [TODO]

Requirements

Use from Crates.io

To use the rust bindings for ArrayFire from crates.io, the following requirements are to be met first.

  1. Download and install ArrayFire binaries based on your operating system.
  2. Set the evironment variable AF_PATH to point to ArrayFire installation root folder.
  3. Make sure you add the path to library files to your path environment variables.
    • On Linux & OSX: do export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$AF_PATH/lib
    • On Windows: Add %AF_PATH%\lib to your PATH environment variable.
  4. Add hal-ml as a dependency in your Cargo.toml

Build from Source

Edit build.conf to modify the build flags. The structure is a simple JSON blob. Currently Rust does not allow key:value pairs to be passed from the CLI. To use an existing ArrayFire installation modify the first three JSON values. You can install ArrayFire using one of the following two ways.

To build arrayfire submodule available in the rust wrapper, you have to do the following.

git submodule update --init --recursive
cargo build

This is recommended way to build Rust wrapper since the submodule points to the most compatible version of ArrayFire the Rust wrapper has been tested with. You can find the ArrayFire dependencies below.

Examples

cargo run --example autoencoder
cargo run --example xor_rnn

Testing

HAL utilizes RUST's test framework to extensively test all of our modules.
We employ gradient checking on individual functions as well as layers.
Testing needs to run on one thread due to our device probing methods.
Furthermore, graphics needs to be disabled for testing [glfw issue].

AF_DISABLE_GRAPHICS=1 RUST_TEST_THREADS=1 cargo test

If you would like to see the results of the test (as well as benchmarks) run:

AF_DISABLE_GRAPHICS=1 RUST_TEST_THREADS=1 cargo test -- --nocapture

Credits

  • Thanks to the arrayfire team for working with me to get the rust bindings up.
  • Keras for inspiration as a lot of functions are similar to their implementation (minus the theano nonsense).
  • Dr. Felix Gers for his insight into internal RTRL
  • Dr. Sepp Hochreiter for advise on LSTM's
You might also like...
Example of Rust API for Machine Learning

rust-machine-learning-api-example Example of Rust API for Machine Learning API example that uses resnet224 to infer images received in base64 and retu

High-level non-blocking Deno bindings to the rust-bert machine learning crate.

bertml High-level non-blocking Deno bindings to the rust-bert machine learning crate. Guide Introduction The ModelManager class manages the FFI bindin

Machine learning Neural Network in Rust

vinyana vinyana - stands for mind in pali language. Goal To implement a simple Neural Network Library in order to understand the maths behind it. This

Source Code for 'Practical Machine Learning with Rust' by Joydeep Bhattacharjee

Apress Source Code This repository accompanies Practical Machine Learning with Rust by Joydeep Bhattacharjee (Apress, 2020). Download the files as a z

An example of using TensorFlow rust bindings to serve trained machine learning models via Actix Web
An example of using TensorFlow rust bindings to serve trained machine learning models via Actix Web

Serving TensorFlow with Actix-Web This repository gives an example of training a machine learning model using TensorFlow2.0 Keras in python, exporting

๐Ÿ† A ranked list of awesome machine learning Rust libraries.

best-of-ml-rust ๐Ÿ† A ranked list of awesome machine learning Rust libraries. This curated list contains 180 awesome open-source projects with a total

Machine learning crate in Rust
Machine learning crate in Rust

DeepRust - Machine learning in Rust Vision To create a deeplearning crate in rust aiming to create a great experience for ML researchers & developers

BudouX-rs is a rust port of BudouX (machine learning powered line break organizer tool).

BudouX-rs BudouX-rs is a rust port of BudouX (machine learning powered line break organizer tool). Note: This project contains the deliverables of the

Mars is a rust machine learning library. [Goal is to make Simple as possible]
Mars is a rust machine learning library. [Goal is to make Simple as possible]

Mars Mars (ma-rs) is an blazingly fast rust machine learning library. Simple and Powerful! ๐Ÿฆ€ ๐Ÿš€ Contribution: Feel free to build this project. This i

Comments
  • Feature/unitary

    Feature/unitary

    Files :

    • src/data/unit_src.rs : generating real and comlex number for unitary layer
    • example/test.rs : temporary file to test unitary module

    Functions :

    • src/layer/unitaryr.rs::forward : forward propagation of unitary layer
    • src/params.rs::addUnitary : initialization of parameters for unitary layer
    opened by dducry 3
  • same build error Win10

    same build error Win10

    Only change I made was to Csrgo.toml to update spmc as the version in there is gone. ArrayFire-rust alone compiles fine

    error[E0277]: (dyn std::ops::Fn(defines::AfError) + 'static) cannot be shared between threads safely --> arrayfire-rust\src\error.rs:25:1 | 25 | pub static DEFAULT_HANDLE_ERROR: &'static ErrorCallback = &handle_error_general; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (dyn std::ops::Fn(defines::AfError) + 'static) cannot be shared between threads safely | = help: within &'static (dyn std::ops::Fn(defines::AfError) + 'static), the trait std::marker::Sync is not implemented for (dyn std::ops::Fn(defines::AfError) + 'static) = note: required because it appears within the type &'static (dyn std::ops::Fn(defines::AfError) + 'static) = note: shared static variables must have a type that implements Sync

    opened by clive-g-brown 5
  • Add thread based data prefetcher

    Add thread based data prefetcher

    Data loading is slow. To resolve this we need a separate thread(s) that prefetch data into a queue which is used then in the actual model to execute (get_batch_*) calls.

    opened by jramapuram 0
Owner
Jason Ramapuram
Making machines learn, one sample at a time.
Jason Ramapuram
A repo for learning how to parallelize computations in the GPU using Apple's Metal, in Rust.

Metal playground in rust Made for learning how to parallelize computations in the GPU using Apple's Metal, in Rust, via the metal crate. Overview The

Lambdaclass 5 Feb 20, 2023
Open deep learning compiler stack for cpu, gpu and specialized accelerators

Open Deep Learning Compiler Stack Documentation | Contributors | Community | Release Notes Apache TVM is a compiler stack for deep learning systems. I

The Apache Software Foundation 8.9k Jan 4, 2023
A Rust library with homemade machine learning models to classify the MNIST dataset. Built in an attempt to get familiar with advanced Rust concepts.

mnist-classifier Ideas UPDATED: Finish CLI Flags Parallelize conputationally intensive functions Class-based naive bayes README Image parsing Confusio

Neil Kaushikkar 0 Sep 2, 2021
A Rust machine learning framework.

Linfa linfa (Italian) / sap (English): The vital circulating fluid of a plant. linfa aims to provide a comprehensive toolkit to build Machine Learning

Rust-ML 2.2k Jan 2, 2023
Machine Learning library for Rust

rusty-machine This library is no longer actively maintained. The crate is currently on version 0.5.4. Read the API Documentation to learn more. And he

James Lucas 1.2k Dec 31, 2022
Machine learning crate for Rust

rustlearn A machine learning package for Rust. For full usage details, see the API documentation. Introduction This crate contains reasonably effectiv

Maciej Kula 547 Dec 28, 2022
Machine learning in Rust.

Rustml Rustml is a library for doing machine learning in Rust. The documentation of the project with a descprition of the modules can be found here. F

null 60 Dec 15, 2022
Machine Learning Library for Rust

autograph Machine Learning Library for Rust undergoing maintenance Features Portable accelerated compute Run SPIR-V shaders on GPU's that support Vulk

null 223 Jan 1, 2023
Fwumious Wabbit, fast on-line machine learning toolkit written in Rust

Fwumious Wabbit is a very fast machine learning tool built with Rust inspired by and partially compatible with Vowpal Wabbit (much love! read more abo

Outbrain 115 Dec 9, 2022
A Machine Learning Framework for High Performance written in Rust

polarlight polarlight is a machine learning framework for high performance written in Rust. Key Features TBA Quick Start TBA How To Contribute Contrib

Chris Ohk 25 Aug 23, 2022