Skip to content

Commit

Permalink
Support to build wheel package on Linux aarch64 platform (#2723)
Browse files Browse the repository at this point in the history
- Add support for building and installing GraphScope on the Linux aarch64 platform
- Fixes some issues related to the learning engine and the `gs` script
- Updates the documentation, Makefile, and the `gs` script to handle the aarch64 platform and its dependencies.
  • Loading branch information
lidongze0629 authored May 23, 2023
1 parent 1d3cd4a commit 51f92ac
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 102 deletions.
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ ifeq ($(UNAME),Darwin)
SUFFIX := dylib
endif

# x86_64 or aarch64
ARCH := $(shell uname -m)

VERSION := $(shell cat $(WORKING_DIR)/VERSION)

## Common
Expand Down Expand Up @@ -70,8 +73,14 @@ client: learning
cd $(CLIENT_DIR) && \
python3 -m pip install -r requirements.txt -r requirements-dev.txt --user && \
python3 setup.py build_ext --inplace --user
python3 -m pip install --user --editable $(CLIENT_DIR)
rm -rf $(CLIENT_DIR)/*.egg-info
if [[ "${ARCH}" == "aarch64" ]]; then \
python3 setup.py bdist_wheel; \
python3 -m pip install --user dist/*.whl; \
rm -fr $(CLIENT_DIR)/build; \
else \
python3 -m pip install --user --editable $(CLIENT_DIR); \
rm -rf $(CLIENT_DIR)/*.egg-info; \
fi

coordinator: client
cd $(COORDINATOR_DIR) && \
Expand Down
17 changes: 16 additions & 1 deletion docs/learning_engine/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ you also need to install the tensorflow.
python3 -m pip install tensorflow==2.8.0
```

Only `v2.11.0` supported under the linux aarch64 platform:

```python
>>> import platform
>>> platform.system()
'Linux'
>>> platform.processor()
'aarch64'
```

```bash
# Install the fixed 'v2.11.0' verion of tensorflow under the linux aarch64 platform
python3 -m pip install tensorflow==2.11.0
```

## Running GraphScope Learning Engine on Local

The `graphscope` package includes everything you need to train GNN models
Expand Down Expand Up @@ -126,4 +141,4 @@ GNN model on your local machine. Next, you may want to learn more about the foll
Next, you may want to learn more about the following topics:

- [Design of the learning engine of GraphScope and its technical details.](learning_engine/design_of_gle)
- [A set of examples with advanced usage, including deploying GLE in a K8s cluster.](learning_engine/guide_and_exmaples)
- [A set of examples with advanced usage, including deploying GLE in a K8s cluster.](learning_engine/guide_and_exmaples)
140 changes: 49 additions & 91 deletions gs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# This script was generated by bashly 0.9.4 (https://bashly.dannyb.co)
# This script was generated by bashly 1.0.2 (https://bashly.dannyb.co)
# Modifying it manually is not recommended

# :wrapper.bash3_bouncer
Expand Down Expand Up @@ -96,18 +96,18 @@ gs_make_usage() {
if [[ -n $long_usage ]]; then
printf "%s\n" "Options:"

# :command.usage_fixed_flags
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo

# :command.usage_flags
# :flag.usage
printf " %s\n" "--install-prefix PREFIX"
printf " Install dependency files to [prefix]. By default, './gs make install' will\n install all the files in '/opt/graphscope/bin', '/opt/graphscope/lib' etc.\n You can specify an installation prefix other than '/opt/graphscope' using\n '--install-prefix', for instance '--install-prefix=\$HOME'.\n"
printf " Default: /opt/graphscope\n"
echo

# :command.usage_fixed_flags
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo

# :command.usage_args
printf "%s\n" "Arguments:"

Expand Down Expand Up @@ -152,11 +152,6 @@ gs_make_image_usage() {
if [[ -n $long_usage ]]; then
printf "%s\n" "Options:"

# :command.usage_fixed_flags
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo

# :command.usage_flags
# :flag.usage
printf " %s\n" "--registry REGISTRY"
Expand All @@ -175,6 +170,11 @@ gs_make_image_usage() {
printf " Whether to use CN located mirrors to speed up download. [Not implemented]\n"
echo

# :command.usage_fixed_flags
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo

# :command.usage_args
printf "%s\n" "Arguments:"

Expand Down Expand Up @@ -217,17 +217,17 @@ gs_dev_usage() {
if [[ -n $long_usage ]]; then
printf "%s\n" "Options:"

# :command.usage_fixed_flags
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo

# :command.usage_flags
# :flag.usage
printf " %s\n" "--local, -l LOCAL"
printf " Local path to the source code of GraphScope.\n"
echo

# :command.usage_fixed_flags
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo

# :command.usage_examples
printf "%s\n" "Examples:"
printf " gs dev\n"
Expand Down Expand Up @@ -261,11 +261,6 @@ gs_test_usage() {
if [[ -n $long_usage ]]; then
printf "%s\n" "Options:"

# :command.usage_fixed_flags
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo

# :command.usage_flags
# :flag.usage
printf " %s\n" "--local"
Expand All @@ -288,6 +283,11 @@ gs_test_usage() {
printf " Default: /tmp/gstest\n"
echo

# :command.usage_fixed_flags
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo

# :command.usage_args
printf "%s\n" "Arguments:"

Expand Down Expand Up @@ -324,11 +324,6 @@ gs_install_deps_usage() {
if [[ -n $long_usage ]]; then
printf "%s\n" "Options:"

# :command.usage_fixed_flags
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo

# :command.usage_flags
# :flag.usage
printf " %s\n" "--cn"
Expand Down Expand Up @@ -368,6 +363,11 @@ gs_install_deps_usage() {
printf " Do not install v6d, for build base docker images, could only be used with\n '--for-analytical'\n"
echo

# :command.usage_fixed_flags
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo

# :command.usage_args
printf "%s\n" "Arguments:"

Expand Down Expand Up @@ -454,8 +454,8 @@ normalize_input() {
}
# :command.inspect_args
inspect_args() {
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
if ((${#args[@]})); then
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
echo args:
for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
else
Expand All @@ -470,6 +470,14 @@ inspect_args() {
echo "- \${other_args[$i]} = ${other_args[$i]}"
done
fi

if ((${#deps[@]})); then
readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort)
echo
echo deps:
for k in "${sorted_keys[@]}"; do echo "- \${deps[$k]} = ${deps[$k]}"; done
fi

}

# :command.user_lib
Expand Down Expand Up @@ -1019,14 +1027,7 @@ install_vineyard() {
make -j"${jobs}"
make install
strip "${V6D_PREFIX}"/bin/vineyard* "${V6D_PREFIX}"/lib/libvineyard*
python3 setup.py bdist_wheel
# This is output fixed wheels to wheelhouse/
python3 -m auditwheel repair dist/*
rm -rf dist/*
python3 setup_bdist.py bdist_wheel
python3 setup_io.py bdist_wheel
mv dist/*.whl wheelhouse/
pip3 install --no-cache wheelhouse/* --user
pip3 install "vineyard==${v6d_version}"
cp -rs "${V6D_PREFIX}"/* "${install_prefix}"/
popd || exit
popd || exit
Expand Down Expand Up @@ -2056,7 +2057,9 @@ gs_make_image_parse_requirements() {
done

# :command.dependencies_filter
if ! command -v docker >/dev/null 2>&1; then
if command -v docker >/dev/null 2>&1; then
deps['docker']="$(command -v docker | head -n1)"
else
printf "missing dependency: docker\n" >&2
exit 1
fi
Expand Down Expand Up @@ -2172,7 +2175,9 @@ gs_dev_parse_requirements() {
done

# :command.dependencies_filter
if ! command -v docker >/dev/null 2>&1; then
if command -v docker >/dev/null 2>&1; then
deps['docker']="$(command -v docker | head -n1)"
else
printf "missing dependency: docker\n" >&2
exit 1
fi
Expand Down Expand Up @@ -2558,66 +2563,19 @@ initialize() {
# :command.run
run() {
declare -A args=()
declare -A deps=()
declare -a other_args=()
declare -a input=()
normalize_input "$@"
parse_requirements "${input[@]}"

case "$action" in
"make")
if [[ ${args['--help']:-} ]]; then
long_usage=yes
gs_make_usage
else
gs_make_command
fi
;;

"make-image")
if [[ ${args['--help']:-} ]]; then
long_usage=yes
gs_make_image_usage
else
gs_make_image_command
fi
;;

"dev")
if [[ ${args['--help']:-} ]]; then
long_usage=yes
gs_dev_usage
else
gs_dev_command
fi
;;

"test")
if [[ ${args['--help']:-} ]]; then
long_usage=yes
gs_test_usage
else
gs_test_command
fi
;;

"install-deps")
if [[ ${args['--help']:-} ]]; then
long_usage=yes
gs_install_deps_usage
else
gs_install_deps_command
fi
;;

"format")
if [[ ${args['--help']:-} ]]; then
long_usage=yes
gs_format_usage
else
gs_format_command
fi
;;

"make") gs_make_command ;;
"make-image") gs_make_image_command ;;
"dev") gs_dev_command ;;
"test") gs_test_command ;;
"install-deps") gs_install_deps_command ;;
"format") gs_format_command ;;
esac
}

Expand Down
38 changes: 33 additions & 5 deletions k8s/internal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ graphscope-darwin-py3:

graphscope-manylinux2014-py3-nodocker:
cd $(WORKING_DIR)/../.. && \
if [[ "${ARCH}" == "aarch64" ]]; then python3 -m pip install grpcio==1.49.1 --no-binary grpcio; \
export AUDITWHEEL_PLAT=manylinux2014_${ARCH}; \
python3 -m pip install grpcio-tools==1.49.1 --no-binary grpcio-tools; fi && \
for _ in {1..5}; do if make INSTALL_PREFIX=${INSTALL_PREFIX}; then break; fi; done && \
for _ in {1..5}; do if $(MAKE_INSTALL_COMMAND); then break; fi; done && \
if [ ${INSTALL_PREFIX} != ${GRAPHSCOPE_HOME} ]; then sudo cp -rsn ${INSTALL_PREFIX}/* ${GRAPHSCOPE_HOME}/; fi && \
Expand Down Expand Up @@ -150,24 +153,49 @@ graphscope-client-manylinux2014-py3-nodocker:
cmake -DKNN=OFF -DWITH_VINEYARD=ON -DTESTING=OFF .. && \
make graphlearn_shared -j`nproc` && \
export LD_LIBRARY_PATH=$(WORKING_DIR)/../../learning_engine/graph-learn/graphlearn/built/lib:$$LD_LIBRARY_PATH && \
if [[ "${ARCH}" == "aarch64" ]]; then export AUDITWHEEL_PLAT=manylinux2014_${ARCH}; fi && \
for py in cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311; do \
cd $(WORKING_DIR)/../../python; \
export PATH=/opt/python/$$py/bin:$$PATH; \
python3 -m pip install -U pip; \
if [[ "$$py" == "cp311-cp311" ]]; then \
python3 -m pip install "numpy==1.23.2" "pandas" "grpcio" "grpcio-tools" wheel "auditwheel==5.0.0"; \
if [[ "${ARCH}" == "aarch64" ]]; then \
python3 -m pip install grpcio==1.49.1 --no-binary grpcio; \
python3 -m pip install grpcio-tools==1.49.1 --no-binary grpcio-tools; \
python3 -m pip install "numpy==1.23.2" "pandas" wheel "auditwheel==5.0.0"; \
else \
python3 -m pip install "numpy==1.23.2" "pandas" "grpcio" "grpcio-tools" wheel "auditwheel==5.0.0"; \
fi; \
elif [[ "$$py" == "cp310-cp310" ]]; then \
python3 -m pip install "numpy==1.21.2" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" wheel "auditwheel==5.0.0"; \
if [[ "${ARCH}" == "aarch64" ]]; then \
python3 -m pip install grpcio==1.49.1 --no-binary grpcio; \
python3 -m pip install grpcio-tools==1.49.1 --no-binary grpcio-tools; \
python3 -m pip install "numpy==1.21.2" "pandas" wheel "auditwheel==5.0.0"; \
else \
python3 -m pip install "numpy==1.21.2" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" wheel "auditwheel==5.0.0"; \
fi; \
elif [[ "$$py" == "cp39-cp39" ]]; then \
python3 -m pip install "numpy==1.19.3" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" wheel "auditwheel==5.0.0"; \
if [[ "${ARCH}" == "aarch64" ]]; then \
python3 -m pip install grpcio==1.49.1 --no-binary grpcio; \
python3 -m pip install grpcio-tools==1.49.1 --no-binary grpcio-tools; \
python3 -m pip install "numpy==1.19.3" "pandas" wheel "auditwheel==5.0.0"; \
else \
python3 -m pip install "numpy==1.19.3" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" wheel "auditwheel==5.0.0"; \
fi; \
else \
python3 -m pip install "numpy==1.18.5" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" wheel "auditwheel==5.0.0"; \
if [[ "${ARCH}" == "aarch64" ]]; then \
python3 -m pip install grpcio==1.49.1 --no-binary grpcio; \
python3 -m pip install grpcio-tools==1.49.1 --no-binary grpcio-tools; \
python3 -m pip install "numpy" "pandas" wheel "auditwheel==5.0.0"; \
else \
python3 -m pip install "numpy==1.18.5" "pandas" "grpcio>=1.49" "grpcio-tools>=1.49" wheel "auditwheel==5.0.0"; \
fi; \
fi; \
sudo rm -rf build; \
sudo rm -rf dist/*.whl; \
python3 setup.py bdist_wheel; \
cd dist; \
auditwheel repair ./*.whl; \
auditwheel repair ./*.whl --plat=manylinux2014_${ARCH}; \
done

graphscope-client-darwin-py3:
Expand Down
7 changes: 5 additions & 2 deletions python/graphscope/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
#

import os
import platform
import sys

# Tensorflow with Python 3.7 requires lower version of protobuf
if sys.version_info.major == 3 and sys.version_info.minor == 7:
# Tensorflow with Python 3.7 and ARM platform requires lower version of protobuf
if (sys.version_info.major == 3 and sys.version_info.minor == 7) or (
platform.system() == "Linux" and platform.processor() == "aarch64"
):
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"

# The gremlinpython has a async event loop, which may conflicts with
Expand Down
Loading

0 comments on commit 51f92ac

Please sign in to comment.