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.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.
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.
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 \
--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 mageSet 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:
cd mage
sudo .cpp/memgraph/environment/os/install_deps.sh install TOOLCHAIN_RUN_DEPSInstall 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.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.