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:
opam switch create raven 5.5.0 eval $(opam env)
Installing from opam
Install the entire ecosystem:
opam install raven
Or install individual libraries:
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
git clone https://github.com/raven-ml/raven cd raven dune pkg lock && dune build
To build a specific library:
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:
(lang dune 3.0) (package (name my_project) (depends ocaml dune nx rune))
And your dune file:
(executable (name main) (libraries nx rune))
Verify your installation
Create a file main.ml:
let () = let x = Nx.linspace Nx.float32 0. 1. 5 in Nx.print x
Build and run:
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:
#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:
- VS Code: Install the OCaml Platform extension
- Emacs: Use ocaml-eglot
- Vim/Neovim: Use ocaml-lsp with your LSP client
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.