Install MAGE graph algorithm library

Use MAGE with an instance installed within a Docker container or on Linux.

The execution of graph algorithms can be accelerated with the GPU, by using the Memgraph X NVIDIA cuGraph version of the library.

Docker

Install Memgraph with Docker using memgraph-platform or memgraph-mage images which include the MAGE library so no additional installation is required to run the graph algorithms on your data.

You can download a specific version of MAGE

For example, if you want to download version 1.1, you should run the following command:

docker run -p 7687:7687 --name memgraph memgraph/memgraph-mage:1.1

Linux

Follow the steps if you want to use the MAGE library with installed Linux based Memgraph package.

Make sure the instance is not running

Algorithms and query modules will be loaded into a Memgraph instance on startup once you install MAGE, so make sure your instances are not running.

Install dependencies

To build from source, you will need:

Set up the machine

Run the following commands:

sudo apt-get update && sudo apt-get install -y \
    libcurl4 \
    libpython3.9 \
    libssl-dev \
    openssl \
    build-essential \
    cmake \
    curl \
    g++ \
    python3 \
    python3-pip \
    python3-setuptools \
    python3-dev \
    clang \
    git \
    --no-install-recommends \
&& sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Download the MAGE source code

Clone the MAGE source code (opens in a new tab) from GitHub:

git clone --recurse-submodules https://github.com/memgraph/mage.git && cd mage

Run the `setup` script

Run the following command:

sudo python3 setup build -p /usr/lib/memgraph/query_modules

If you don't need all of the algorithms you can build only some of them based on the laguauge.

To build C++ based algorithms run:

sudo python3 setup build -p /usr/lib/memgraph/query_modules --lang cpp

To build Python based algorithms run:

sudo python3 setup build -p /usr/lib/memgraph/query_modules --lang python

The script will generate a dist directory with all the needed files.

It will also copy the contents of the newly created dist directory to /usr/lib/memgraph/query_modules. Memgraph loads algorithms and modules from this directory.

If something isn't installed properly, the setup script will stop the installation process. If you have any questions, contact us on Discord (opens in a new tab).

Start a Memgraph instance

Algorithms and query modules will be loaded into a Memgraph instance on startup

If your instance was already running you will need to execute the following query to load them:

CALL mg.load_all();

If your changes are not loaded, make sure to restart the instance by running systemctl stop memgraph and systemctl start memgraph.

MAGE × NVIDIA cuGraph on Docker

At the moment, no new images are built. If you would benefit from new images, please let us know by creating a GitHub issue on the MAGE repository (opens in a new tab).

Follow this guide to install Memgraph with NVIDIA cuGraph (opens in a new tab) GPU-powered graph algorithms.

Prerequisites

To be able to run cuGraph analytics, make sure you have compatible infrastructure. The exact system requirements are available at the NVIDIA RAPIDS site (opens in a new tab), and include an NVIDIA Pascal (or better) GPU and up-to-date CUDA & NVIDIA drivers.

If you want to run MAGE × NVIDIA cuGraph in Docker, install:

Download the image from Docker Hub

Pull the image and run it:

docker run --rm --gpus all -p 7687:7687 -p 7444:7444 memgraph/memgraph-mage:1.3-cugraph-22.02-cuda-11.5

Depending on your environment, different versions of MAGE-cuGraph-CUDA can be installed:

docker run --gpus all -p 7687:7687 -p 7444:7444 memgraph/memgraph-mage:${MAGE_VERSION}-cugraph-${CUGRAPH_VERSION}-cuda-${CUDA_VERSION}

To see the available versions, explore Memgraph's Docker Hub and search for the images tagged memgraph-mage (opens in a new tab).

MAGE × NVIDIA cuGraph on Linux

At the moment, no new images are built. If you would benefit from new images, please let us know by creating a GitHub issue on the MAGE repository (opens in a new tab).

To use the MAGE × NVIDIA cuGraph (opens in a new tab) with installed Linux based Memgraph package (opens in a new tab) you need to install it natively from the source

Prerequisites

To be able to run cuGraph analytics, make sure you have compatible infrastructure. The exact system requirements are available at the NVIDIA RAPIDS site (opens in a new tab), and include an NVIDIA Pascal (or better) GPU and up-to-date CUDA & NVIDIA drivers.

If building MAGE × NVIDIA cuGraph locally, these requirements apply (tested on Ubuntu):

If you want to build MAGE × NVIDIA cuGraph locally, install:

Make sure the instance is not running

Algorithms and query modules will be loaded into a Memgraph instance on startup once you install MAGE, so make sure your instances are not running.

Download the source code

Download the MAGE source code from GitHub (opens in a new tab):

git clone https://github.com/memgraph/mage.git

Run the `setup` script

Run the script to generate a dist directory with all the needed files:

python3 setup build -p /usr/lib/memgraph/query_modules --gpu

It will also copy the contents of the newly created dist directory to /usr/lib/memgraph/query_modules.

The --gpu flag enables building the cuGraph dependencies and creating the shared library with cuGraph algorithms that are loaded into Memgraph.

If something isn't installed properly, the setup script will stop the installation process. If you have any questions, contact us on Discord (opens in a new tab).

Start a Memgraph instance

Algorithms and query modules will be loaded into a Memgraph instance on startup

If your instance was already running you will need to execute the following query to load them:

CALL mg.load_all();

If your changes are not loaded, make sure to restart the instance by running systemctl stop memgraph and systemctl start memgraph.