github ↗
docs menu

Installation

Prerequisites

Raven requires OCaml 5.5 or later and opam.

If you don't have opam installed, follow the official instructions. Then create a switch:

bash
opam switch create raven 5.5.0
eval $(opam env)

Installing from opam

Install the entire ecosystem:

bash
opam install raven

Or install individual libraries:

bash
opam install nx          # just arrays
opam install rune        # arrays + autodiff
opam install kaun        # arrays + neural networks (add rune and vega to train)
opam install brot        # tokenization
opam install talon       # dataframes

Building from source

bash
git clone https://github.com/raven-ml/raven
cd raven
dune pkg lock && dune build

To build a specific library:

bash
dune build packages/nx            # just nx
dune build packages/kaun          # kaun + its dependencies

System dependencies

Raven builds and installs with no system dependencies beyond OCaml.

Compiling kernels at run time, with Rune.jit, uses the platform's compiler: clang on the CPU, NVRTC (from the CUDA toolkit) on NVIDIA, and comgr (from ROCm) on AMD; macOS includes Metal's. Kernels already in the on-disk cache need none of them, and eager code on the host needs nothing.

Using Raven in your project

Add libraries to your dune-project:

dune
(lang dune 3.0)
(package
 (name my_project)
 (depends
  ocaml
  dune
  nx
  rune))

And your dune file:

dune
(executable
 (name main)
 (libraries nx rune))

Verify your installation

Create a file main.ml:

ocaml
let () =
  let x = Nx.linspace Nx.float32 0. 1. 5 in
  Nx.print x

Build and run:

bash
dune exec ./main.exe

You should see five evenly-spaced values printed.

Using Raven in a toplevel

In the ocaml toplevel, findlib loads a library with its dependencies, and nx.top makes the toplevel print arrays:

ocaml
#use "topfind";;
#require "rune";;
#require "nx.top";;

Inside a dune project, #use_output "dune ocaml top";; loads the project's libraries instead, and arrays print only if the project depends on nx.top. Load the libraries one way or the other, never both: the second load fails with rig is already loaded in this process, and the toplevel must then be restarted.

Editor setup

For the best development experience, use an editor with OCaml LSP support:

Troubleshooting

Opam switch issues: Run eval $(opam env) after creating or switching opam switches.

Build failures: Check your OCaml version with ocaml --version. Raven requires 5.5.0 or later.

Getting help: Report issues at github.com/raven-ml/raven/issues.

edit this page ↗