Owl requires OCaml >=4.06.0. Please make sure you have a working OCaml environment before you start installing Owl. Here is a guide on [Install OCaml].

Owl’s installation is rather trivial. There are four possible ways as shown below, from the most straightforward one to the least one.

Option 1: Install from OPAM

Thanks to the folks in OCaml Labs, OPAM makes package management in OCaml much easier than before. You can simply type the following in the command line to start.

opam install owl

However, Owl’s current version on OPAM is 0.3.0, and it lags way behind the development in master branch and misses many new features.

On the other hand, this document is tightly synchronised with the master branch. This means that you may not be able to try out the stuff I teach here. If you want to try the newest features, I recommend the other ways to install Owl, as below.

Option 2: Pull from Docker Hub

Owl’s docker image is perfectly synced with master branch. The image is always automatically built whenever there are new commits. You can check the building history on [Docker Hub].

You only need to pull the image then start a container.

docker pull ryanrhymes/owl
docker run -t -i ryanrhymes/owl

Besides the complete Owl system, the docker image also contains an enhanced OCaml toplevel - utop. You can start utop in the container and try out some examples.

The source code of Owl is stored in /root/owl directory. You can modify the source code and rebuild the system directly in the started container.

Option 3: Pin the Dev-Repo

opam pin allows you to pin the local code to Owl’s development repository on Github. The first command opam depext installs all the dependencies Owl needs.

opam depext owl
opam pin add owl --dev-repo

Option 4: Compile from Source

This is my favourite option. First, you need to clone the repository.

git clone

Second, you need to figure out the missing dependencies and install them.

jbuilder external-lib-deps --missing @install

Last, this is perhaps the most classic step.

make && make install

If your OPAM is older than V2 beta4, you need one extra steps. This is due to a bug in OPAM which copies the compiled library into /.opam/4.06.0/lib/stubslibs rather than /.opam/4.06.0/lib/stublibs. If you don’t upgrade OPAM, then you need to manually move file from stubslib to stublib folder, then everything should work.


The most important dependency is OpenBLAS. Linking to the correct OpenBLAS is the key to achieve the best performance. Depending on the specific platform, you can use yum, apt-get, brew to install the binary format. For example on my Mac OSX, the installation looks like this:

brew install homebrew/science/openblas

However, installing from OpenBLAS source code leads to way better performance in my own experiment. OpenBLAS already contains an implementation of LAPACKE, as long as you have a Fortran complier installed on your computer, the LAPACKE will be compiled and included in the installation automatically.

Another benefit of installing from OpenBLAS source is: some systems’ native package management tool installs very old version of OpenBLAS which misses some functions Owl requires.

Integration to Toplevel

Owl is well integrated with utop. You can use utop to try out the experiments in our tutorials. If you want utop to automatically load Owl for you, you can also edit .ocamlinit file in your home folder by adding the following lines. (Note that the library name is owl with lowercase o.)

#require "owl_top"

The owl_top is the toplevel library of Owl, it automatically loads owl core library and installs the corresponding pretty printers of various data types.