Install MAGE graph algorithm library
Use MAGE with an instance installed within a Docker container, from a prebuilt package on Ubuntu or CentOS, or built from source.
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 3.2, you should run the following
command:
docker run -p 7687:7687 --name memgraph memgraph/memgraph-mage:3.2The following tags are available on Docker Hub:
x.y- production MAGE imagex.y-relwithdebinfo- contains debugging symbols andgdbx.y-malloc- Memgraph compiled withmallocinstead ofjemalloc(x86_64 only)x.y-relwithdebinfo-cuda- Memgraph built with CUDA support* - available since version3.6.1.
*To run GPU-accelerated algorithms, you need to launch the container with the --gpus all flag.
This requires the installation of NVIDIA Container Toolkit. See the
NVIDIA Container Toolkit documentation
for more details.
For versions prior to 3.2, MAGE image tags included both MAGE and Memgraph versions, e.g.
docker run -p 7687:7687 --name memgraph memgraph/memgraph-mage:3.1.1-memgraph-3.1.1A no-ml image (e.g. 3.1.1-memgraph-3.1.1-no-ml) was also provided, but this has now been
discontinued as of 3.2 onwards.
Install from a package
On Ubuntu 24.04 (DEB x86_64 and aarch64) and CentOS 9 / CentOS 10 (RPM, x86_64 only), MAGE is
available as a prebuilt memgraph-mage package, so you don’t have to build it
from source.
Install Memgraph
Install the Memgraph package first — the memgraph-mage package depends on a
matching memgraph package of the same version. Follow the
Ubuntu or
CentOS installation guide.
Download the MAGE package
Download the memgraph-mage package that matches your Memgraph version and distro
from the direct download
links. For example:
# Ubuntu 24.04
wget https://download.memgraph.com/memgraph-mage/v3.12.0/ubuntu-24.04/memgraph-mage_3.12.0-1_amd64.deb
# CentOS 9
wget https://download.memgraph.com/memgraph-mage/v3.12.0/centos-9/memgraph-mage-3.12.0-1.centos-9.x86_64.rpmCUDA and cuGraph variants are also available for Ubuntu — see the download links page.
Install MAGE
Install the package with your distribution’s package manager so its dependencies are resolved:
# Ubuntu (DEB)
sudo apt install ./memgraph-mage_3.12.0-1_amd64.deb
# CentOS (RPM)
sudo dnf install ./memgraph-mage-3.12.0-1.centos-9.x86_64.rpmDuring installation the package downloads and installs the Python dependencies the MAGE query modules need, so the machine needs network access.
Restart Memgraph
Restart Memgraph so the newly installed modules are loaded:
sudo systemctl restart memgraphBuild from source (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:
- Python3
- Make
- CMake
- Clang
- UUID
- Rust and Cargo
Set up the machine
Run the following commands:
sudo apt-get update && sudo apt-get install -y \
libcurl4 \
libpython3.12 \
libssl-dev \
openssl \
build-essential \
cmake \
curl \
g++ \
python3 \
python3-pip \
python3-setuptools \
python3-dev \
clang \
git \
pkg-config \
uuid-dev \
xmlsec1 \
ninja-build \
--no-install-recommends Download the MAGE source code
Clone the Memgraph source code from GitHub:
git clone https://github.com/memgraph/memgraph.git && cd memgraph/Set up the toolchain
Download and install the Memgraph Toolchain:
curl -L https://s3-eu-west-1.amazonaws.com/deps.memgraph.io/toolchain-v7/toolchain-v7-binaries-ubuntu-24.04-amd64.tar.gz -o toolchain.tar.gz
sudo tar xzvfm toolchain.tar.gz -C /optInstall runtime dependencies for the toolchain:
sudo ./environment/os/install_deps.sh install TOOLCHAIN_RUN_DEPSInstall Rust and Python dependencies
Run the following command to install Rust and Python dependencies:
cd mage
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH="/root/.cargo/bin:${PATH}"
python3 -m pip install -r python/requirements.txt
python3 -m pip install -r ../src/auth/reference_modules/requirements.txt
python3 -m pip install torch-sparse torch-cluster torch-spline-conv torch-geometric torch-scatter -f https://data.pyg.org/whl/torch-2.6.0+cpu.html
python3 -m pip install dgl -f https://data.dgl.ai/wheels/torch-2.6/repo.htmlTo install the dependencies for GPU-accelerated algorithms, you need to use the GPU-specific requirements file:
python3 -m pip install -r python/requirements-gpu.txtRun the `setup` script
Run the following command:
source /opt/toolchain-v7/activate
python3 setup build
sudo cp -r dist/* /usr/lib/memgraph/query_modulesIf 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:
python3 setup build --lang cppTo build Python based algorithms run:
python3 setup build --lang pythonThe 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.
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.