Open Machine Intelligence Framework for Hackers. (GPU/CPU)

Related tags

leaf
Overview

Leaf • Join the chat at https://gitter.im/autumnai/leaf Build Status Crates.io License

Introduction

Leaf is a open Machine Learning Framework for hackers to build classical, deep or hybrid machine learning applications. It was inspired by the brilliant people behind TensorFlow, Torch, Caffe, Rust and numerous research papers and brings modularity, performance and portability to deep learning.

Leaf has one of the simplest APIs, is lean and tries to introduce minimal technical debt to your stack.

See the [Leaf - Machine Learning for Hackers][leaf-book] book for more.

Leaf is a few months old, but thanks to its architecture and Rust, it is already one of the fastest Machine Intelligence Frameworks available.

See more Deep Neural Networks benchmarks on [Deep Learning Benchmarks][deep-learning-benchmarks-website].

Leaf is portable. Run it on CPUs, GPUs, and FPGAs, on machines with an OS, or on machines without one. Run it with OpenCL or CUDA. Credit goes to Collenchyma and Rust.

Leaf is part of the [Autumn][autumn] Machine Intelligence Platform, which is working on making AI algorithms 100x more computational efficient.

We see Leaf as the core of constructing high-performance machine intelligence applications. Leaf's design makes it easy to publish independent modules to make e.g. deep reinforcement learning, visualization and monitoring, network distribution, automated preprocessing or scaleable production deployment easily accessible for everyone.

Disclaimer: Leaf is currently in an early stage of development. If you are experiencing any bugs with features that have been implemented, feel free to create a issue.

Getting Started

Documentation

To learn how to build classical, deep or hybrid machine learning applications with Leaf, check out the [Leaf - Machine Learning for Hackers][leaf-book] book.

For additional information see the Rust API Documentation or the [Autumn Website][autumn].

Or start by running the Leaf examples.

We are providing a Leaf examples repository, where we and others publish executable machine learning models build with Leaf. It features a CLI for easy usage and has a detailed guide in the project README.md.

Leaf comes with an examples directory as well, which features popular neural networks (e.g. Alexnet, Overfeat, VGG). To run them on your machine, just follow the install guide, clone this repoistory and then run

# The examples currently require CUDA support.
cargo run --release --no-default-features --features cuda --example benchmarks alexnet

Installation

Leaf is build in Rust. If you are new to Rust you can install Rust as detailed here. We also recommend taking a look at the official Rust - Getting Started Guide.

To start building a machine learning application (Rust only for now. Wrappers are welcome) and you are using Cargo, just add Leaf to your Cargo.toml:

[dependencies]
leaf = "0.2.1"

If you are on a machine that doesn't have support for CUDA or OpenCL you can selectively enable them like this in your Cargo.toml:

[dependencies]
leaf = { version = "0.2.1", default-features = false }

[features]
default = ["native"] # include only the ones you want to use, in this case "native"
native  = ["leaf/native"]
cuda    = ["leaf/cuda"]
opencl  = ["leaf/opencl"]

More information on the use of feature flags in Leaf can be found in FEATURE-FLAGS.md

Contributing

If you want to start hacking on Leaf (e.g. adding a new Layer) you should start with forking and cloning the repository.

We have more instructions to help you get started in the CONTRIBUTING.md.

We also has a near real-time collaboration culture, which happens here on Github and on the Leaf Gitter Channel.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.

Ecosystem / Extensions

We designed Leaf and the other crates of the [Autumn Platform][autumn] to be as modular and extensible as possible. More helpful crates you can use with Leaf:

  • Cuticula: Preprocessing Framework for Machine Learning
  • Collenchyma: Portable, HPC-Framework on any hardware with CUDA, OpenCL, Rust

Support / Contact

  • With a bit of luck, you can find us online on the #rust-machine-learning IRC at irc.mozilla.org,
  • but we are always approachable on Gitter/Leaf
  • For bugs and feature request, you can create a Github issue
  • For more private matters, send us email straight to our inbox: [email protected]
  • Refer to [Autumn][autumn] for more information

Changelog

You can find the release history at the CHANGELOG.md. We are using Clog, the Rust tool for auto-generating CHANGELOG files.

License

Licensed under either of

at your option.

Issues
  • Remove redundant .enumerate() calls and fix cargo bench compilation

    Remove redundant .enumerate() calls and fix cargo bench compilation

    I've refactured and fixed some trivial things while reading the code.

    cargo bench compiles but panics in runtime, I think it should be easy to fix but it looks like benches are deprecated.

    opened by alexandermorozov 14
  • perf/solver: don't zero fill weight gradients

    perf/solver: don't zero fill weight gradients

    Please verify this PR! I'm not completely sure that it's correct.

    Weight gradients aren't used before they are overwritten at backpropagation step, so initialization is redundant.

    If #89 is applied, this patch improves performance 30% on leaf-examples mnist.

    opened by alexandermorozov 11
  • [WIP] The 'Leaf: Machine Learning for hackers' book

    [WIP] The 'Leaf: Machine Learning for hackers' book

    This PR is a work in progress. So far I added the 1. Leaf and 2. Layers chapters.

    Feedback for the overall structure of the book as well as the general ideas and style of the first two chapters are highly welcome.

    There are probably a lot of typos and grammar mistakes in there. You don't have to bother yet pointing them out, the text might change quickly.

    REFERENCE: #91

    opened by MichaelHirn 10
  • feat/layers: add tanh layer

    feat/layers: add tanh layer

    Still WIP. Needs polishing and documentation

    opened by MichaelHirn 10
  • Fixed typo: crucial from curcial

    Fixed typo: crucial from curcial

    Changed typo from word curcial to crucial

    docs PR: commit-message 
    opened by palerdot 9
  • Create Leaf Book / high-level documentation

    Create Leaf Book / high-level documentation

    I feel like, the entrance barrier for (Rust) Developers to engage with Leaf and Machine Learning, for contributions and hacking-away purposes, is still far too high. Partly because the concepts of Machine Learning (Deep Learning) are not yet widely known and partly because not many are familiar with the general design of a Machine Learning framework - compared e.g. to the general design of a Web framework.

    The Leaf Book, should provide a practical introduction to Deep Learning for developers. Explain the easy Leaf API and provide examples for popular use-cases like adding a new Layer, Machine Learning across multiple devices and co. After reading it, a developer should feel comfortable hacking on Leaf, even if she has no prior knowledge about Deep Learning ( Deep Learning is really easy).

    @hobofan pointed out in #45 interactive documentation for Layers. I am not sure to what extent they can be provided here with the Leaf Book. For the interactive layer documentation, I have something with Jupyter in mind, which would require a Rust kernel first, though. But other options for interactive layer documentation are welcome.

    For the book I am trying mdBook as it gives a nice layout and allows it to place the book inside the leaf project. Feedback on the choice is welcome.

    docs contributing 
    opened by MichaelHirn 8
  • feat/serialization: add serialization

    feat/serialization: add serialization

    WIP, the commit for deserialization is still missing because it needs a bit of polish

    Will resolve #14, #15

    opened by hobofan 7
  • The `phloem` crate (currently used by `leaf`) seems to be deprecated in favour of collenchyma's `SharedTensor`

    The `phloem` crate (currently used by `leaf`) seems to be deprecated in favour of collenchyma's `SharedTensor`

    I also noticed that the collenchyma crate version seemed to be a little behind - I figure you must be busy with other work at the moment, but I just thought I'd ask what your plans are for updating. Are you currently waiting on developments upstream? Or has this simply not been updated yet due to lack of time?

    question 
    opened by mitchmindtree 7
  • feat/activations: add in-place activations

    feat/activations: add in-place activations

    Activations can now be calculated in-place, requiring less memory. To use it, the same blob name should be supplied as input and output to a activation layer.

    Example:

    // set up linear1 layer
    let linear1_cfg = LinearConfig { output_size: 1568 };
    let mut lnr1_cfg = LayerConfig::new("linear1", LayerType::Linear(linear1_cfg));
    lnr1_cfg.add_input("data");
    lnr1_cfg.add_output("linear1_out");
    net_cfg.add_layer(lnr1_cfg);
    // set up sigmoid layer
    let mut sigmoid_cfg = LayerConfig::new("sigmoid", LayerType::Sigmoid);
    sigmoid_cfg.add_input("linear1_out"); // same input and output
    sigmoid_cfg.add_output("linear1_out"); // same input and output
    net_cfg.add_layer(sigmoid_cfg);
    
    opened by hobofan 6
  • is leaf still active?

    is leaf still active?

    opened by MyraBaba 7
  • Reflect the current status of the project

    Reflect the current status of the project

    Proper stewardship requires actually updating the project README, when a project has been orphaned. #108 #122

    opened by DeadZen 1
  • cannot run example files in leaf

    cannot run example files in leaf

    Hi All, I am new here. I have cuda and cuda nn installed with paths setup. I cannot run the example files for some reason. Am I missing something? System is Ubuntu 16.04 `[email protected]:~$ cd rust_leaf_tutorials/leaf [email protected]:~/rust_leaf_tutorials/leaf$ cargo run --release --no-default-features --features cuda --example benchmarks alexnet Compiling linear-map v0.0.4 Compiling num-traits v0.1.37 Compiling pkg-config v0.3.9 Compiling winapi v0.2.8 Compiling byteorder v0.4.2 Compiling lazy_static v0.1.16 Compiling rustc-serialize v0.3.24 Compiling utf8-ranges v0.1.3 Compiling libc v0.2.23

    Compiling log v0.3.7 Compiling rblas v0.0.11 Compiling capnp v0.6.2 Compiling winapi-build v0.1.1 Compiling regex-syntax v0.3.9 Compiling bitflags v0.3.3 Compiling num-integer v0.1.34 Compiling enum_primitive v0.1.1 Compiling rand v0.3.15 Compiling kernel32-sys v0.2.2 Compiling time v0.1.37 Compiling memchr v0.1.11 Compiling num-iter v0.1.33 Compiling cublas-sys v0.1.0 Compiling cudnn-sys v0.0.3 Compiling thread-id v2.0.0 Compiling thread_local v0.2.7 Compiling aho-corasick v0.5.3 Compiling cudnn v1.3.1 Compiling cublas v0.2.0 Compiling timeit v0.1.2 Compiling capnpc v0.6.2 Compiling num-bigint v0.1.37 Compiling num-complex v0.1.37 Compiling regex v0.1.80 Compiling num-rational v0.1.36 Compiling num v0.1.37 Compiling collenchyma v0.0.8 Compiling collenchyma-blas v0.2.0 Compiling collenchyma-nn v0.3.4 Compiling leaf v0.2.1 (file:///home/akhileshsk/rust_leaf_tutorials/leaf) Compiling leaf v0.2.1 error[E0004]: non-exhaustive patterns: &mut Cuda(_) not covered --> /home/akhileshsk/.cargo/registry/src/github.com-1ecc6299db9ec823/leaf-0.2.1/src/util.rs:28:11 | 28 | match mem { | ^^^ pattern &mut Cuda(_) not covered

    error[E0004]: non-exhaustive patterns: &Cuda(_) not covered --> /home/akhileshsk/.cargo/registry/src/github.com-1ecc6299db9ec823/leaf-0.2.1/src/solvers/mod.rs:77:24 | 77 | match result.get(native.device()).unwrap() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern &Cuda(_) not covered

    error: aborting due to 2 previous errors

    error: Could not compile leaf. Build failed, waiting for other jobs to finish... error: build failed [email protected]:~/rust_leaf_tutorials/leaf$ [email protected]:~/rust_leaf_tutorials/leaf$ ^C [email protected]:~/rust_leaf_tutorials/leaf$ `

    opened by aspk 3
  • Provide docker image and Dockerfile

    Provide docker image and Dockerfile

    It would be great to provide the docker image and Dockerfile for newbie developers.

    We can also use that container to run leaf in the cloud much more easily.

    opened by tobegit3hub 1
  • build error with rustc 1.12

    build error with rustc 1.12

    I have got build error with rustc 1.12 on debian stretch.

    $ RUST_BACKTRACE=1 cargo build
       Compiling leaf v0.2.1 (file:///home/<user>/work/leaf)
       Compiling num-rational v0.1.35
    Build failed, waiting for other jobs to finish...
    error: failed to run custom build command for `leaf v0.2.1 (file:///home/<user>/work/leaf)`
    Process didn't exit successfully: `/home/<user>/work/leaf/target/debug/build/leaf-87f43ad88e5c8bb2/build-script-build` (exit code: 101)
    --- stderr
    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Failed, description: "Error while trying to execute `capnp compile`: Failed: No such file or directory (os error 2).  Please verify that version 0.5.2 or higher of the capnp executable is installed on your system. See https://capnproto.org/install.html" }', src/libcore/result.rs:788
    stack backtrace:
       1:     0x55e338350a6b - std::sys::backtrace::tracing::imp::write::h00e948915d1e4c72
       2:     0x55e338355ebf - std::panicking::default_hook::_{{closure}}::h7b8a142818383fb8
       3:     0x55e33835511d - std::panicking::default_hook::h41cf296f654245d7
       4:     0x55e3383557d5 - std::panicking::rust_panic_with_hook::h4cbd7ca63ce1aee9
       5:     0x55e338355622 - std::panicking::begin_panic::h93672d0313d5e8e9
       6:     0x55e338355591 - std::panicking::begin_panic_fmt::hd0daa02942245d81
       7:     0x55e338355511 - rust_begin_unwind
       8:     0x55e33838c97f - core::panicking::panic_fmt::hbfc935564d134c1b
       9:     0x55e3382950c2 - core::result::unwrap_failed::h14ae321fa6665b8d
                            at /build/rustc-1.12.0+dfsg1/src/libcore/result.rs:29
      10:     0x55e338294251 - _<core..result..Result<T, E>>::unwrap::hbe110bf6bea72ca6
                            at /build/rustc-1.12.0+dfsg1/src/libcore/result.rs:726
      11:     0x55e338297306 - build_script_build::main::he5071e1b00fcfe0e
                            at /home/<user>/work/leaf/build.rs:4
      12:     0x55e33835d896 - __rust_maybe_catch_panic
      13:     0x55e33835480d - std::rt::lang_start::h53bf99b0829cc03c
      14:     0x55e3382974e3 - main
      15:     0x7fa0f6ae52b0 - __libc_start_main
      16:     0x55e3382935e9 - _start
      17:                0x0 - <unknown>
    

    What should I see to make this work?

    opened by jinserk 2
  • Current status of leaf?

    Current status of leaf?

    From this post:

    Which is why Max and I will suspend the development of Leaf and focus on new ventures.

    Is this accurate? If so, should the README mention so?

    Autumn is also still listed on http://rust-lang.org/friends.html, is Autumn still a thing? If so, will the company continue to use Rust?

    opened by anp 45
  • cannot compile the example

    cannot compile the example

    Hi, all I try to compile and run leaf example with the following command, cargo run --release --no-default-features --features cuda --example benchmarks alexnet but got errors like this

    In function `convolution_descriptor::ConvolutionDescriptor::new::hbe3406e228523108khb':
    cudnn.0.rs:(.text._ZN22convolution_descriptor21ConvolutionDescriptor3new20hbe3406e228523108khbE+0x29c): undefined reference to `cudnnSetConvolutionNdDescriptor_v3'
    cudnn.0.rs:(.text._ZN22convolution_descriptor21ConvolutionDescriptor3new20hbe3406e228523108khbE+0x346): undefined reference to `cudnnSetConvolutionNdDescriptor_v3'
    cudnn.0.rs:(.text._ZN22convolution_descriptor21ConvolutionDescriptor3new20hbe3406e228523108khbE+0x3a2): undefined reference to `cudnnSetConvolutionNdDescriptor_v3'
    

    I am using rustc 1.8.0 with cargo 0.10.0.

    please give me some hints.

    thanks

    opened by jianingy 5
  • This project needs capnproto and should mention it

    This project needs capnproto and should mention it

    When naively trying to build an example project, one gets this:

    thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Failed, description: "Error while trying to execute `capnp compile`: Failed: No such file or directory (os error 2).  Please verify that version 0.5.2 or higher of the capnp executable is installed on your system. See https://capnproto.org/install.html" }', src/libcore/result.rs:746
    note: Run with `RUST_BACKTRACE=1` for a backtrace.
    
    

    You should mention that you require capnproto to be installed in the system beforehand.

    opened by svenstaro 2
  • Convert Leaf to the new memory access API

    Convert Leaf to the new memory access API

    This is follow-up to autumnai/collenchyma#37 autumnai/collenchyma#62.

    opened by alexandermorozov 0
  • Use of ArcLocks

    Use of ArcLocks

    What do you think about removing ArcLocks from Leaf codebase? There is a lot of .read().unwrap(), Arc::new(RwLock::new(..)) and then let inputs_locked: Vec<_> = inputs.iter().map(|b| b.read().unwrap()).collect() that make code harder to read. Users of Leaf also have to wrap inputs in ArcLocks.

    I think when autumnai/collenchyma#37 is implemented, there would be less problems with borrowing, and ArcLocks can be removed (but I'm not completely sure yet).

    Or are there plans to introduce multithreading that require all inputs/outputs/weights to be wrapped in this way?

    opened by alexandermorozov 0
Owner
Autumn
Autumn
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 Aug 25, 2021
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 123 Aug 28, 2021
Xaynet represents an agnostic Federated Machine Learning framework to build privacy-preserving AI applications.

xaynet Xaynet: Train on the Edge with Federated Learning Want a framework that supports federated learning on the edge, in desktop browsers, integrate

XayNet 149 Sep 12, 2021
Rust language bindings for TensorFlow

TensorFlow Rust provides idiomatic Rust language bindings for TensorFlow. Notice: This project is still under active development and not guaranteed to

null 3.3k Sep 16, 2021
Rust based Cross-GPU Machine Learning

HAL : Hyper Adaptive Learning Rust based Cross-GPU Machine Learning. Why Rust? This project is for those that miss strongly typed compiled languages.

Jason Ramapuram 79 Jul 9, 2021
Rust language bindings for Faiss

Faiss-rs This project provides Rust bindings to Faiss, the state-of-the-art vector search and clustering library. Installing as a dependency Currently

Eduardo Pinho 48 Sep 7, 2021
The Hacker's Machine Learning Engine

Juice This is the workspace project for juice - machine learning frameworks for hackers coaster - underlying math abstraction coaster-nn coaster-blas

spearow 801 Sep 7, 2021
🚀 efficient approximate nearest neighbor search algorithm collections library written in Rust 🦀 .

?? efficient approximate nearest neighbor search algorithm collections library written in Rust ?? .

Hora-Search 2.1k Sep 12, 2021
Efficient ML solutions for long-tailed demands.

MegFlow MegFlow 是一个面向视觉应用的流式计算框架, 目标是简单、高性能、帮助机器学习应用快速落地。 Features 基于 async-std[features=tokio1] 的高效异步运行时调度器 简洁的基于 toml 的建图描述格式 支持静态、动态、共享子图 支持 Rust/P

旷视天元 MegEngine 49 Sep 12, 2021
A Rusty CUDA wrapper

cuda-oxide cuda-oxide is a safe wrapper for CUDA. With cuda-oxide you can execute and coordinate CUDA kernels. Safety Philosophy cuda-oxide does not o

Max Bruce 27 Aug 17, 2021
Compile-time creation of neural networks

Mushin: Compile-time creation of neural networks Mushin is a Japanese term used in martial arts that refers to the state of mind obtained by practice.

Aitor Ruano 193 Aug 27, 2021
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 7.2k Sep 15, 2021
Orkhon: ML Inference Framework and Server Runtime

Orkhon: ML Inference Framework and Server Runtime Latest Release License Build Status Downloads Gitter What is it? Orkhon is Rust framework for Machin

Theo M. Bulut 103 Sep 2, 2021
l2 is a fast, Pytorch-style Tensor+Autograd library written in Rust

l2 • ?? A Pytorch-style Tensor+Autograd library written in Rust Installation • Contributing • Authors • License • Acknowledgements Made by Bilal Khan

Bilal Khan 136 Aug 17, 2021
🦀 Example of serving deep learning models in Rust with batched prediction

rust-dl-webserver This project provides an example of serving a deep learning model with batched prediction using Rust. In particular it runs a GPT2 m

Evan Pete Walsh 21 Sep 16, 2021
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

vaaaaanquish 12 Sep 10, 2021
Tiny, no-nonsense, self-contained, Tensorflow and ONNX inference

Sonos' Neural Network inference engine. This project used to be called tfdeploy, or Tensorflow-deploy-rust. What ? tract is a Neural Network inference

Sonos, Inc. 1.1k Sep 17, 2021
A neural network, and tensor dynamic automatic differentiation implementation for Rust.

Corgi A neural network, and tensor dynamic automatic differentiation implementation for Rust. BLAS The BLAS feature can be enabled, and requires CBLAS

Patrick Song 14 Aug 29, 2021
Tangram is an automated machine learning framework designed for programmers.

Tangram Tangram is an automated machine learning framework designed for programmers. Run tangram train to train a model from a CSV file on the command

Tangram 763 Sep 18, 2021