Getting started

Install with git

The simplest way of installing a specific version of GeomLoss is to use some advanced pip syntax:

pip install git+[full]

Alternatively, you may:

  1. Install PyTorch.

  2. Install the KeOps library.

  3. Clone the GeomLoss repository:

    git clone
  4. Add /path/to/geomloss to your $PYTHONPATH.

Build the documentation on Google Cloud

To generate this website on a fresh Google Compute session, first install CUDA and nvcc by following these instructions. You should then type the following lines in the SSH prompt:

# Install pip and the necessary packages to run all tutorials:
sudo apt install python3-pip
pip3 install numpy GPUtil cmake ninja sklearn scipy imageio scikit-image
pip3 install torch torchvision
pip3 install dipy nibabel vtk pyvtk SimpleITK
pip3 install sphinx sphinx-gallery recommonmark sphinxcontrib-httpdomain sphinx_rtd_theme plyfile >> install.log

# Clone the latest versions of keops and geomloss, adding them to the path
git clone --quiet --recursive keops/  >> install.log
git clone --quiet geomloss/  >> install.log
echo "export PYTHONPATH=$PYTHONPATH:~/keops/:~/geomloss/" >> ~/.bashrc

# Launch a "detachable" session:
cd geomloss/doc

# Run the doc once to compile all the KeOps routines:
make html
# Clean up everything...
make clean
# And re-run all scripts to get the correct timings:
make html

# Zip everything into an archive:
sudo apt install zip
zip -r _build/

# On the *local* machine: download the zipped documentation.
# Typically, with a properly configured "gcloud" command:
gcloud compute scp root@nvidia-gpu-cloud-pytorch-image-1-vm:/home/jean_feydy/geomloss/doc/ ~

Build the documentation on Google Colab

Alternatively, you may also generate this website on a free Google Colab session. To reproduce our results (with longer runtimes), please create a new Colab notebook and to type the following instructions in the first few cells:

# Mount Google drive to save the final documentation
from google.colab import drive

# Make sure that GDrive is mounted correctly
!ls gdrive/'My Drive'

# Install sphinx for Python 3 (instead of the default Python 2)
!pip uninstall sphinx
!pip3 install sphinx

# Install the dependencies for sphinx and KeOps
!pip install numpy GPUtil cmake ninja > install.log
!pip install sphinx-gallery recommonmark sphinxcontrib-httpdomain sphinx_rtd_theme plyfile >> install.log

# Download KeOps...
!pip install pykeops  >> install.log

# Download GeomLoss
!git clone  >> install.log

# Make sure that new scripts will have access to GeomLoss
import os
os.environ['PYTHONPATH'] += ":/content/geomloss/"

# Put GeomLoss in the current environment
import sys

# First run, to compile everything
%cd /content/geomloss/doc
!make html

# Second run, to get the correct timings without compile times
!make clean
!make html

# Now, just download "" and upload it on the website :-)
!zip -r _build
!cp /content/gdrive/'My Drive'

That’s it!