Skip to content

Memgraph 3.1.1 #1199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 28, 2025
36 changes: 32 additions & 4 deletions pages/advanced-algorithms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Advance your graph analysis capabilities with Memgraph's tailored a

import { Steps } from 'nextra/components'
import {CommunityLinks} from '/components/social-card/CommunityLinks'

import { Callout } from 'nextra/components'

# Advanced algorithms

Expand Down Expand Up @@ -47,14 +47,15 @@ programming languages and they are all runnable inside Memgraph.

### Install MAGE

If you started Memgraph with the `memgraph-platform` or `memgraph-mage` Docker
If you started Memgraph with the `memgraph-mage` Docker
image, MAGE is already included and you can skip to step 3.

If you are using Linux, you can [install MAGE from
source](/advanced-algorithms/install-mage#linux).

The execution of graph algorithms can be accelerated with the GPU by using the
[Memgraph X NVIDIA cuGraph](/advanced-algorithms/install-mage#mage--nvidia-cugraph) version of the library.
<Callout type="info">
We currently do not produce MAGE images with cuGraph (since version 1.3). If this is something you require, please raise an [issue](https://github.com/memgraph/mage/issues)
</Callout>

### Load query modules

Expand Down Expand Up @@ -82,6 +83,33 @@ MAGE compatibility with Memgraph versions.

| MAGE version | Memgraph version |
|--------------|-------------------|
| 3.1 | 3.1 |
| 3.0 | 3.0 |
| 1.22 | 2.22 |
| 1.22.1 | 2.22.1 |
| 1.21 | 2.21 |
| 1.20.1 | 2.20.1 |
| 1.20 | 2.20 |
| 1.19 | 2.19 |
| 1.18.1 | 2.18.1 |
| 1.18 | 2.18 |
| 1.17 | 2.17 |
| 1.16.1 | 2.16.1 |
| 1.16 | 2.16 |
| 1.15.2 | 2.15.2 |
| 1.15.1 | 2.15.1 |
| 1.15 | 2.15 |
| 1.14.1 | 2.14.1 |
| 1.14 | 2.14 |
| 1.13 | 2.13 |
| 1.12.1 | 2.12.1 |
| 1.12 | 2.12 |
| 1.11.1 | 2.11 |
| 1.11.0 | 2.11 |
| 1.10 | 2.10.1 |
| 1.9 | 2.10.0 |
| 1.8 | 2.9 |
| 1.7 | 2.8 |
| >= 1.6 | >= 2.5.2 |
| >= 1.4 | >= 2.4.0 |
| >= 1.0 | >= 2.0.0 |
Expand Down
55 changes: 55 additions & 0 deletions pages/advanced-algorithms/available-algorithms/migrate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,61 @@ CREATE (u1)-[:FRIENDS_WITH]->(u2);

---

### `neo4j()`

With the `migrate.neo4j()` procedure, you can access Neo4j and migrate your data to Memgraph.
The resulting nodes and edges are converted into a stream of rows which can include labels, properties, and primitives.
**Streaming of raw node and relationship objects is not supported**, and users are advised to migrate all the necessary identifiers
in order to recreate the same graph in Memgraph.

{<h4 className="custom-header"> Input: </h4>}

- `label_or_rel_or_query: str` ➡ Label name (written in format `(:Label)`), relationship name (written in format `[:rel_type]`) or a plain cypher query.
- `config: mgp.Map` ➡ Connection parameters (as in `gqlalchemy.Neo4j`). Notable parameters are `host[String]` and `port[Integer]`.
- `config_path` ➡ Path to a JSON file containing configuration parameters.
- `params: mgp.Nullable[mgp.Any] (default=None)` ➡ Query parameters (if applicable).

{<h4 className="custom-header"> Output: </h4>}

- `row: mgp.Map` ➡ The result table as a stream of rows.
- When retrieving nodes using the `(:Label)` syntax, row will have the following keys: `labels` and `properties`.
- When retrieving relationships using the `[:REL_TYPE]` syntax, row will have the following keys: `from_labels`, `to_labels`, `from_properties`, `to_properties` and `edge_properties`.
- When retrieving results using a plain Cypher query, row will have keys identical to the returned column names from the Cypher query.

{<h4 className="custom-header"> Usage: </h4>}

#### Retrieve nodes of certain label and create them in Memgraph
```cypher
CALL migrate.neo4j('(:Person)', {host: 'localhost', port: 7687})
YIELD row
WITH row.labels AS labels, row.properties as props
CREATE (n:labels) SET n += row.props
```

#### Retrieve relationships of certain type and create them in Memgraph
```cypher
CALL migrate.neo4j('[:KNOWS]', {host: 'localhost', port: 7687})
YIELD row
WITH row.from_labels AS from_labels,
row.to_labels AS to_labels,
row.from_properties AS from_properties,
row.to_properties AS to_properties,
row.edge_properties AS edge_properties
MATCH (p1:Person {id: row.from_properties.id})
MATCH (p2:Person {id: row.to_properties.id})
CREATE (p1)-[r:KNOWS]->(p2)
SET r += edge_properties;
```

#### Retrieve information from Neo4j using an arbitrary Cypher query
```cypher
CALL migrate.neo4j('MATCH (n) RETURN count(n) as cnt', {host: 'localhost', port: 7687})
YIELD row
RETURN row.cnt as cnt;
```

---

### `oracle_db()`

With the `migrate.oracle_db()` procedure, you can access Oracle DB and migrate your data to Memgraph.
Expand Down
185 changes: 32 additions & 153 deletions pages/advanced-algorithms/install-mage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import { Callout } from 'nextra/components'
Use MAGE with an instance installed within a [Docker container](#docker) or on
[Linux](#linux).

The execution of graph algorithms can be accelerated with the GPU, by using the
[Memgraph X NVIDIA
cuGraph](#mage--nvidia-cugraph) version of the
library.

## Docker

[Install Memgraph with Docker](/getting-started/install-memgraph/docker) using
Expand All @@ -27,11 +22,11 @@ data.

You can download a specific version of MAGE

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

```shell
docker run -p 7687:7687 --name memgraph memgraph/memgraph-mage:1.1
docker run -p 7687:7687 --name memgraph memgraph/memgraph-mage:3.1.1-memgraph-3.1.1
```

</Callout>
Expand Down Expand Up @@ -65,7 +60,7 @@ Run the following commands:
```bash
sudo apt-get update && sudo apt-get install -y \
libcurl4 \
libpython3.9 \
libpython3.12 \
libssl-dev \
openssl \
build-essential \
Expand All @@ -78,8 +73,10 @@ sudo apt-get update && sudo apt-get install -y \
python3-dev \
clang \
git \
--no-install-recommends \
&& sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
pkg-config \
uuid-dev \
libxmlsec1-dev xmlsec1 \
--no-install-recommends
```

{<h3 className="custom-header">Download the MAGE source code</h3>}
Expand All @@ -90,23 +87,41 @@ Clone the [MAGE source code](https://github.com/memgraph/mage) from GitHub:
git clone --recurse-submodules https://github.com/memgraph/mage.git && cd mage
```

{<h3 className="custom-header">Set up the toolchain</h3>}

Download and install the [Memgraph Toolchain](https://memgraph.com/docs/getting-started/build-memgraph-from-source#toolchain-installation-procedure):
```bash
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:
```bash
cd mage
sudo .cpp/memgraph/environment/os/install_deps.sh install TOOLCHAIN_RUN_DEPS
```

{<h3 className="custom-header">Install Rust and Python dependencies</h3>}

Run the following command to install Rust and Python dependencies:

```shell
curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& export PATH="/root/.cargo/bin:${PATH}" \
&& python3 -m pip install -r /mage/python/requirements.txt \
&& python3 -m pip install torch-sparse torch-cluster torch-spline-conv torch-geometric torch-scatter -f https://data.pyg.org/whl/torch-1.12.0+cu102.html \
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
```

{<h3 className="custom-header">Run the `setup` script</h3>}

Run the following command:

```shell
sudo python3 setup build -p /usr/lib/memgraph/query_modules
source /opt/toolchain-v6/activate
python3 setup build
sudo cp -r dist/* /usr/lib/memgraph/query_modules
```

<Callout type="info">
Expand All @@ -116,13 +131,13 @@ If you don't need all of the algorithms you can build only some of them based on
To build C++ based algorithms run:

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

To build Python based algorithms run:

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

</Callout>
Expand Down Expand Up @@ -152,139 +167,3 @@ If your changes are not loaded, make sure to restart the instance by running
`systemctl stop memgraph` and `systemctl start memgraph`.

</Steps>

## MAGE × NVIDIA cuGraph on Docker

<Callout type="info">

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](https://github.com/memgraph/mage).

</Callout>

Follow this guide to install Memgraph with [**NVIDIA
cuGraph**](https://github.com/rapidsai/cugraph) GPU-powered graph algorithms.

<Steps>

{<h3 className="custom-header">Prerequisites</h3>}

To be able to run cuGraph analytics, make sure you have compatible
infrastructure. The exact system requirements are available at the [**NVIDIA
RAPIDS site**](https://rapids.ai/start.html#requirements), 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:

- Docker
- Official [**NVIDIA driver**](https://www.nvidia.com/download/index.aspx) for
your operating system.
- To run on NVIDIA-powered GPUs, RAPIDS requires Docker CE v19.03+ and
[**nvidia-container-toolkit**](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker)
installed.
- Legacy Docker CE v17-18 users require the installation of the
[**nvidia-docker2**](<https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(version-2.0)>)
package.

{<h3 className="custom-header">Download the image from Docker Hub</h3>}

Pull the image and run it:

```shell
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:

```shell
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**](https://hub.docker.com/r/memgraph/memgraph-mage/tags).

</Steps>

## MAGE × NVIDIA cuGraph on Linux

<Callout type="info">

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](https://github.com/memgraph/mage).

</Callout>

To use the MAGE × [**NVIDIA cuGraph**](https://github.com/rapidsai/cugraph) with
[installed Linux based Memgraph package](https://memgraph.com/download) you need
to install it natively from the source

<Steps>

{<h3 className="custom-header">Prerequisites</h3>}

To be able to run cuGraph analytics, make sure you have compatible
infrastructure. The exact system requirements are available at the [**NVIDIA
RAPIDS site**](https://rapids.ai/start.html#requirements), 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:

- Official [**NVIDIA driver**](https://www.nvidia.com/download/index.aspx) for
your operating system.
- [**CMake**](https://cmake.org/) version above 3.20
- [**NVIDIA CUDA developer toolkit**](https://developer.nvidia.com/cuda-toolkit)
– CUDA version 11.6
- System dependencies: `libblas-dev`, `liblapack-dev`, `libboost-all-dev`
- [**NVIDIA NCCL communications library**](https://developer.nvidia.com/nccl)

{<h3 className="custom-header">Make sure the instance is not running</h3>}

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.

{<h3 className="custom-header">Download the source code</h3>}

Download the MAGE source code from [**GitHub**](https://github.com/memgraph/mage):

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

{<h3 className="custom-header">Run the `setup` script</h3>}

Run the script to generate a `dist` directory with all the needed files:
```shell
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](https://discord.gg/memgraph).**

{<h3 className="custom-header">Start a Memgraph instance</h3>}

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`.

</Steps>
Loading