-
Notifications
You must be signed in to change notification settings - Fork 33
Add CUDA build + packaging workflow #672
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
gitbuda
merged 14 commits into
add-torch-gpu-docker-support
from
add-torch-gpu-docker-support-matt
Oct 5, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1ca7e63
added cuda build
mattkjames7 e9962a5
use correct torch packages/repo/cuda
mattkjames7 a57b093
added missing requirement
mattkjames7 9d135e3
hacked into working
mattkjames7 581fecf
parallel execution in a working state
mattkjames7 16dea8d
move worker to subdirectory
mattkjames7 8b95ad6
revert changes to CPU containers
mattkjames7 f639622
line ending
mattkjames7 7881969
fixed formatting
mattkjames7 2acf322
workflow fix
mattkjames7 1db2c03
another workflow fix
mattkjames7 f1ccb3d
workflow
mattkjames7 b017a5e
boolean
mattkjames7 438e8d9
boolean
mattkjames7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,249 @@ | ||
ARG PY_VERSION_DEFAULT=3.12 | ||
ARG MGBUILD_IMAGE | ||
|
||
FROM $MGBUILD_IMAGE as builder | ||
|
||
USER root | ||
|
||
ARG TARGETARCH | ||
ARG PY_VERSION_DEFAULT | ||
ARG BUILD_TYPE | ||
ARG CACHE_PRESENT | ||
ENV BUILD_TYPE=${BUILD_TYPE} | ||
ENV PY_VERSION ${PY_VERSION_DEFAULT} | ||
ARG CUSTOM_MIRROR | ||
|
||
|
||
# This modifies the apt configuration to rety 3 times | ||
RUN echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries | ||
|
||
# If CUSTOM_MIRROR is set, replace the default archive.ubuntu.com | ||
# and security.ubuntu.com URIs in your .sources file | ||
RUN if [ -n "$CUSTOM_MIRROR" ]; then \ | ||
sed -E -i \ | ||
-e '/^URIs:/ s#https?://[^ ]*archive\.ubuntu\.com#'"$CUSTOM_MIRROR"'#g' \ | ||
-e '/^URIs:/ s#https?://security\.ubuntu\.com#'"$CUSTOM_MIRROR"'#g' \ | ||
/etc/apt/sources.list.d/ubuntu.sources; \ | ||
fi | ||
|
||
# Essentials for production/dev | ||
RUN apt-get update && apt-get install -y \ | ||
libcurl4 `memgraph` \ | ||
libpython${PY_VERSION} `memgraph` \ | ||
libssl-dev `memgraph` \ | ||
openssl `memgraph` \ | ||
build-essential `mage-memgraph` \ | ||
cmake `mage-memgraph` \ | ||
curl `mage-memgraph` \ | ||
g++ `mage-memgraph` \ | ||
python3 `mage-memgraph` \ | ||
python3-pip `mage-memgraph` \ | ||
python3-setuptools `mage-memgraph` \ | ||
python3-dev `mage-memgraph` \ | ||
clang `mage-memgraph` \ | ||
git `mage-memgraph` \ | ||
unixodbc-dev `mage-memgraph` \ | ||
libboost-all-dev `mage-memgraph` \ | ||
uuid-dev \ | ||
gdb \ | ||
procps \ | ||
libc6-dbg \ | ||
libxmlsec1-dev xmlsec1 \ | ||
libatomic1 \ | ||
--no-install-recommends \ | ||
&& ln -s /usr/bin/$(ls /usr/bin | grep perf) /usr/bin/perf \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
COPY memgraph-${TARGETARCH}.deb . | ||
|
||
RUN dpkg -i memgraph-${TARGETARCH}.deb && rm memgraph-${TARGETARCH}.deb | ||
|
||
# move memgraph HOME so that mounting /var/lib/memgraph as a volume doesn't break Python | ||
RUN mkdir -pv /home/memgraph && \ | ||
usermod -d /home/memgraph memgraph && \ | ||
chown -R memgraph:memgraph /home/memgraph | ||
|
||
ENV LD_LIBRARY_PATH /usr/lib/memgraph/query_modules | ||
|
||
|
||
WORKDIR /mage | ||
COPY . /mage | ||
|
||
#hacks so we can do everything under the `memgraph` user | ||
RUN chown -R memgraph: /mage && \ | ||
mkdir -pv /usr/lib/memgraph/query_modules && \ | ||
chown -R memgraph: /usr/lib/memgraph/query_modules | ||
USER memgraph | ||
|
||
# First install requirements | ||
RUN python3 -m pip install --no-cache-dir -r /mage/python/requirements-gpu.txt --break-system-packages && \ | ||
python3 -m pip install --no-cache-dir -r /mage/python/tests/requirements.txt --break-system-packages && \ | ||
python3 -m pip install --no-cache-dir -r /usr/lib/memgraph/auth_module/requirements.txt --break-system-packages && \ | ||
python3 -m pip install --no-cache-dir torch-sparse torch-cluster torch-spline-conv torch-geometric torch-scatter --break-system-packages -f https://data.pyg.org/whl/torch-2.6.0+cu126.html; \ | ||
python3 -m pip install --no-cache-dir dgl==2.5.0 -f https://data.dgl.ai/wheels/torch-2.6/repo.html --break-system-packages; \ | ||
rm -fr /home/memgraph/.cache/pip | ||
|
||
# Build query modules | ||
SHELL ["/bin/bash", "-c"] | ||
RUN source /opt/toolchain-v6/activate && curl https://sh.rustup.rs -sSf | sh -s -- -y \ | ||
&& export PATH="$HOME/.cargo/bin:${PATH}" \ | ||
&& rustup toolchain install 1.85 \ | ||
&& rustup default 1.85 \ | ||
&& python3 /mage/setup build -p /usr/lib/memgraph/query_modules/ --cpp-build-flags CMAKE_BUILD_TYPE=${BUILD_TYPE} \ | ||
&& chown -R memgraph: /mage | ||
|
||
|
||
# Memgraph listens for Bolt Protocol on this port by default. | ||
EXPOSE 7687 | ||
|
||
|
||
|
||
FROM ubuntu:24.04 as base | ||
|
||
USER root | ||
|
||
ARG TARGETARCH | ||
ARG PY_VERSION_DEFAULT=3.12 | ||
ARG MAGE_COMMIT | ||
ARG BUILD_TYPE | ||
ENV BUILD_TYPE=${BUILD_TYPE} | ||
ENV PY_VERSION ${PY_VERSION_DEFAULT} | ||
ENV MAGE_COMMIT=${MAGE_COMMIT} | ||
ARG CUSTOM_MIRROR | ||
|
||
# This modifies the apt configuration to rety 3 times | ||
RUN echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries | ||
|
||
# If CUSTOM_MIRROR is set, replace the default archive.ubuntu.com | ||
# and security.ubuntu.com URIs in your .sources file | ||
RUN if [ -n "$CUSTOM_MIRROR" ]; then \ | ||
sed -E -i \ | ||
-e '/^URIs:/ s#https?://[^ ]*archive\.ubuntu\.com#'"$CUSTOM_MIRROR"'#g' \ | ||
-e '/^URIs:/ s#https?://security\.ubuntu\.com#'"$CUSTOM_MIRROR"'#g' \ | ||
/etc/apt/sources.list.d/ubuntu.sources; \ | ||
fi | ||
|
||
# Essentials for production/dev | ||
RUN apt-get update && \ | ||
apt-get install -y curl && \ | ||
curl -sSL -O https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb && \ | ||
dpkg -i packages-microsoft-prod.deb && \ | ||
rm packages-microsoft-prod.deb && \ | ||
apt-get update && \ | ||
ACCEPT_EULA=Y apt-get install -y msodbcsql18 unixodbc-dev && \ | ||
apt-get install -y \ | ||
libcurl4 `memgraph` \ | ||
libpython${PY_VERSION} `memgraph` \ | ||
libssl-dev `memgraph` \ | ||
openssl `memgraph` \ | ||
python3 `mage-memgraph` \ | ||
python3-pip `mage-memgraph` \ | ||
python3-setuptools `mage-memgraph` \ | ||
python3-dev `mage-memgraph` \ | ||
libc6-dbg \ | ||
adduser \ | ||
libgomp1 \ | ||
libaio1t64 \ | ||
libatomic1 \ | ||
--no-install-recommends \ | ||
&& ln -s /usr/bin/$(ls /usr/bin | grep perf) /usr/bin/perf \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ | ||
if [ "${TARGETARCH}" = "arm64" ]; then \ | ||
ln -s /usr/lib/aarch64-linux-gnu/libaio.so.1t64 /usr/lib/aarch64-linux-gnu/libaio.so.1; \ | ||
else \ | ||
ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1; \ | ||
fi | ||
|
||
# install memgraph | ||
COPY memgraph-${TARGETARCH}.deb . | ||
|
||
# fix `memgraph` UID and GID for compatibility with previous Debian releases | ||
RUN groupadd -g 103 memgraph && \ | ||
useradd -u 101 -g memgraph -m -d /home/memgraph -s /bin/bash memgraph && \ | ||
dpkg -i memgraph-${TARGETARCH}.deb && \ | ||
rm memgraph-${TARGETARCH}.deb | ||
|
||
ENV LD_LIBRARY_PATH /usr/lib/memgraph/query_modules | ||
|
||
# Copy modules | ||
COPY --from=builder /usr/lib/memgraph/query_modules/ /usr/lib/memgraph/query_modules/ | ||
COPY --from=builder /usr/lib/memgraph/auth_module/ /usr/lib/memgraph/auth_module/ | ||
|
||
# Copy Python build | ||
COPY --from=builder /usr/local/lib/python${PY_VERSION}/ /usr/local/lib/python${PY_VERSION}/ | ||
COPY --from=builder --chown=memgraph:memgraph /home/memgraph/.local/ /home/memgraph/.local/ | ||
|
||
# copy script to convert to dev container | ||
COPY --from=builder /mage/make-dev-container.sh /make-dev-container.sh | ||
|
||
FROM base as prod | ||
|
||
USER root | ||
|
||
ARG TARGETARCH | ||
ARG PY_VERSION_DEFAULT=3.12 | ||
ARG MAGE_COMMIT | ||
ARG BUILD_TYPE | ||
ENV BUILD_TYPE=${BUILD_TYPE} | ||
ENV PY_VERSION ${PY_VERSION_DEFAULT} | ||
ENV MAGE_COMMIT=${MAGE_COMMIT} | ||
ARG CUSTOM_MIRROR | ||
|
||
# Copy e2e tests | ||
COPY --from=builder --chown=memgraph:memgraph /mage/e2e/ /mage/e2e/ | ||
COPY --from=builder --chown=memgraph:memgraph /mage/e2e_correctness/ /mage/e2e_correctness/ | ||
COPY --from=builder --chown=memgraph:memgraph /mage/test_e2e_correctness.py /mage/test_e2e_correctness.py | ||
COPY --from=builder --chown=memgraph:memgraph /mage/run_e2e_correctness_tests.sh /mage/run_e2e_correctness_tests.sh | ||
|
||
# Copy requirements | ||
COPY --from=builder --chown=memgraph:memgraph /mage/python/requirements.txt /mage/python/requirements.txt | ||
COPY --from=builder --chown=memgraph:memgraph /mage/python/tests/requirements.txt /mage/python/tests/requirements.txt | ||
|
||
RUN if [ -n "$CUSTOM_MIRROR" ]; then \ | ||
sed -E -i \ | ||
-e "/^URIs:/ s#${CUSTOM_MIRROR}/ubuntu/#https://archive.ubuntu.com/ubuntu/#g" \ | ||
-e "/^URIs:/ s#${CUSTOM_MIRROR}/ubuntu/#https://security.ubuntu.com/ubuntu/#g" \ | ||
/etc/apt/sources.list.d/ubuntu.sources; \ | ||
fi | ||
|
||
USER memgraph | ||
EXPOSE 7687 | ||
|
||
ENTRYPOINT ["/usr/lib/memgraph/memgraph"] | ||
CMD [""] | ||
|
||
|
||
FROM base as debug | ||
|
||
USER root | ||
|
||
ARG TARGETARCH | ||
ARG PY_VERSION_DEFAULT=3.12 | ||
ARG MAGE_COMMIT | ||
ARG BUILD_TYPE | ||
ENV BUILD_TYPE=${BUILD_TYPE} | ||
ENV PY_VERSION ${PY_VERSION_DEFAULT} | ||
ENV MAGE_COMMIT=${MAGE_COMMIT} | ||
ARG CUSTOM_MIRROR | ||
|
||
# Add gdb | ||
RUN apt-get update && apt-get install -y \ | ||
gdb \ | ||
--no-install-recommends \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
# Copy entire mage repo | ||
COPY --from=builder --chown=memgraph:memgraph /mage/ /mage/ | ||
|
||
RUN if [ -n "$CUSTOM_MIRROR" ]; then \ | ||
sed -E -i \ | ||
-e "/^URIs:/ s#${CUSTOM_MIRROR}/ubuntu/#https://archive.ubuntu.com/ubuntu/#g" \ | ||
-e "/^URIs:/ s#${CUSTOM_MIRROR}/ubuntu/#https://security.ubuntu.com/ubuntu/#g" \ | ||
/etc/apt/sources.list.d/ubuntu.sources; \ | ||
fi | ||
|
||
USER memgraph | ||
EXPOSE 7687 | ||
|
||
ENTRYPOINT ["/usr/lib/memgraph/memgraph"] | ||
CMD [""] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / SonarCloud
GitHub Actions should not be vulnerable to script injections High