Install MAGE graph algorithm library
Use MAGE with an instance installed within a Docker container or on Linux.
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.1.1
, you should run the following
command:
docker run -p 7687:7687 --name memgraph memgraph/memgraph-mage:3.1.1-memgraph-3.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:
- 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 \
libxmlsec1-dev xmlsec1 \
--no-install-recommends
Download the MAGE source code
Clone the MAGE source code from GitHub:
git clone --recurse-submodules https://github.com/memgraph/mage.git && cd mage
Set up the toolchain
Download and install the Memgraph Toolchain:
curl -L https://s3-eu-west-1.amazonaws.com/deps.memgraph.io/toolchain-v6/toolchain-v6-binaries-ubuntu-24.04-amd64.tar.gz -o toolchain.tar.gz
sudo tar xzvfm toolchain.tar.gz -C /opt
Install runtime dependencies for the toolchain:
cd mage
sudo .cpp/memgraph/environment/os/install_deps.sh install TOOLCHAIN_RUN_DEPS
Install Rust and Python dependencies
Run the following command to install Rust and Python dependencies:
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 cpp/memgraph/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.3.0+cpu.html
python3 -m pip install dgl -f https://data.dgl.ai/wheels/torch-2.3/repo.html
Run the `setup` script
Run the following command:
source /opt/toolchain-v6/activate
python3 setup build
sudo cp -r dist/* /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:
python3 setup build --lang cpp
To build Python based algorithms run:
python3 setup build --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.
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
.