From b23feccafd8e35cde33f8eddab5f307bc1d17665 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 13 Dec 2022 00:21:16 -0500 Subject: [PATCH 1/9] build aarch64 wheels --- .github/workflows/build_wheel.yml | 18 +++++++++++++++++- doc/install/easy-install.md | 2 +- pyproject.toml | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_wheel.yml b/.github/workflows/build_wheel.yml index 273aa8d71f..d1c991c27f 100644 --- a/.github/workflows/build_wheel.yml +++ b/.github/workflows/build_wheel.yml @@ -51,16 +51,32 @@ jobs: - os: windows-2019 python: 310 platform_id: win_amd64 + # linux-aarch64 + - os: ubuntu-latest + python: 37 + platform_id: manylinux_aarch64 + - os: ubuntu-latest + python: 38 + platform_id: manylinux_aarch64 + - os: ubuntu-latest + python: 39 + platform_id: manylinux_aarch64 + - os: ubuntu-latest + python: 310 + platform_id: manylinux_aarch64 steps: - uses: actions/checkout@v2 with: submodules: true + - uses: docker/setup-qemu-action@v2 + name: Setup QEMU + if: matrix.platform_id == 'manylinux_aarch64' - uses: actions/setup-python@v2 name: Install Python with: python-version: '3.8' - - run: python -m pip install cibuildwheel==2.11.2 + - run: python -m pip install cibuildwheel==2.11.3 - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse env: diff --git a/doc/install/easy-install.md b/doc/install/easy-install.md index 0d9577613f..97bc0aa223 100644 --- a/doc/install/easy-install.md +++ b/doc/install/easy-install.md @@ -95,7 +95,7 @@ Or install the CPU version without CUDA supported: pip install deepmd-kit[cpu] ``` -The supported platform includes Linux x86-64 with GNU C Library 2.28 or above, macOS x86-64, and Windows x86-64. +The supported platform includes Linux x86-64 and aarch64 with GNU C Library 2.28 or above, macOS x86-64, and Windows x86-64. A specific version of TensorFlow which is compatible with DeePMD-kit will be also installed. :::{Warning} diff --git a/pyproject.toml b/pyproject.toml index 5e6b389653..f2e8793b5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,7 @@ build = ["cp37-*", "cp38-*", "cp39-*", "cp310-*"] skip = ["*-win32", "*-manylinux_i686", "*-musllinux*"] # TODO: bump to "latest" tag when CUDA supports GCC 12 manylinux-x86_64-image = "quay.io/pypa/manylinux_2_28_x86_64:2022-11-19-1b19e81" +manylinux-aarch64-image = "quay.io/pypa/manylinux_2_28_aarch64:2022-11-19-1b19e81" [tool.cibuildwheel.macos] repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} --ignore-missing-dependencies" From a6e91da7e6c5db6c4f0f2d8b7cac1798e2a6bfde Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 13 Dec 2022 00:28:33 -0500 Subject: [PATCH 2/9] fix cuda url --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f2e8793b5c..c1cc58497b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,7 @@ repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest repair-wheel-command = "auditwheel repair --exclude libtensorflow_framework.so.2 --exclude libtensorflow_framework.so.1 --exclude libtensorflow_framework.so -w {dest_dir} {wheel}" environment-pass = ["CIBW_BUILD"] environment = { DP_VARIANT="cuda" } -before-all = "yum config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo && yum install -y cuda-11-8" +before-all = "yum config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel8/$(uname -m)/cuda-rhel8.repo && yum install -y cuda-11-8" # selectively turn of lintner warnings, always include reasoning why any warning should # be silenced From 94a619875809b9cdc959e3ed9154d2ab798150ca Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 13 Dec 2022 00:43:00 -0500 Subject: [PATCH 3/9] disable cuda --- pyproject.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c1cc58497b..14e8735a19 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,11 @@ repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest repair-wheel-command = "auditwheel repair --exclude libtensorflow_framework.so.2 --exclude libtensorflow_framework.so.1 --exclude libtensorflow_framework.so -w {dest_dir} {wheel}" environment-pass = ["CIBW_BUILD"] environment = { DP_VARIANT="cuda" } -before-all = "yum config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel8/$(uname -m)/cuda-rhel8.repo && yum install -y cuda-11-8" +before-all = """ +if [ "$(uname -m)" == "x86_64" ] then + yum config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo && yum install -y cuda-11-8 +fi +""" # selectively turn of lintner warnings, always include reasoning why any warning should # be silenced From 083a1096bb8c0da3525908bc8e4912d7edcefca5 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 13 Dec 2022 00:45:12 -0500 Subject: [PATCH 4/9] set DP_VARIANT --- .github/workflows/build_wheel.yml | 17 +++++++++++++++++ pyproject.toml | 3 +-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_wheel.yml b/.github/workflows/build_wheel.yml index d1c991c27f..5bbfd1e5d9 100644 --- a/.github/workflows/build_wheel.yml +++ b/.github/workflows/build_wheel.yml @@ -16,54 +16,70 @@ jobs: - os: ubuntu-latest python: 37 platform_id: manylinux_x86_64 + dp_variant: cuda - os: ubuntu-latest python: 38 platform_id: manylinux_x86_64 + dp_variant: cuda - os: ubuntu-latest python: 39 platform_id: manylinux_x86_64 + dp_variant: cuda - os: ubuntu-latest python: 310 platform_id: manylinux_x86_64 + dp_variant: cuda # macos-x86-64 - os: macos-latest python: 37 platform_id: macosx_x86_64 + dp_variant: cpu - os: macos-latest python: 38 platform_id: macosx_x86_64 + dp_variant: cpu - os: macos-latest python: 39 platform_id: macosx_x86_64 + dp_variant: cpu - os: macos-latest python: 310 platform_id: macosx_x86_64 + dp_variant: cpu # win-64 - os: windows-2019 python: 37 platform_id: win_amd64 + dp_variant: cpu - os: windows-2019 python: 38 platform_id: win_amd64 + dp_variant: cpu - os: windows-2019 python: 39 platform_id: win_amd64 + dp_variant: cpu - os: windows-2019 python: 310 platform_id: win_amd64 + dp_variant: cpu # linux-aarch64 - os: ubuntu-latest python: 37 platform_id: manylinux_aarch64 + dp_variant: cpu - os: ubuntu-latest python: 38 platform_id: manylinux_aarch64 + dp_variant: cpu - os: ubuntu-latest python: 39 platform_id: manylinux_aarch64 + dp_variant: cpu - os: ubuntu-latest python: 310 platform_id: manylinux_aarch64 + dp_variant: cpu steps: - uses: actions/checkout@v2 with: @@ -83,6 +99,7 @@ jobs: CIBW_BUILD_VERBOSITY: 1 CIBW_ARCHS: all CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} + DP_VARIANT: {{ matrix.dp_variant }} - uses: actions/upload-artifact@v2 with: path: ./wheelhouse/*.whl diff --git a/pyproject.toml b/pyproject.toml index 14e8735a19..b605a18a18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,8 +62,7 @@ repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest [tool.cibuildwheel.linux] repair-wheel-command = "auditwheel repair --exclude libtensorflow_framework.so.2 --exclude libtensorflow_framework.so.1 --exclude libtensorflow_framework.so -w {dest_dir} {wheel}" -environment-pass = ["CIBW_BUILD"] -environment = { DP_VARIANT="cuda" } +environment-pass = ["CIBW_BUILD", "DP_VARIANT"] before-all = """ if [ "$(uname -m)" == "x86_64" ] then yum config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo && yum install -y cuda-11-8 From 55a024227fa58aa9883489609c9526ec3a08f075 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 13 Dec 2022 00:48:05 -0500 Subject: [PATCH 5/9] fix typo --- .github/workflows/build_wheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheel.yml b/.github/workflows/build_wheel.yml index 5bbfd1e5d9..0d41a5db72 100644 --- a/.github/workflows/build_wheel.yml +++ b/.github/workflows/build_wheel.yml @@ -99,7 +99,7 @@ jobs: CIBW_BUILD_VERBOSITY: 1 CIBW_ARCHS: all CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} - DP_VARIANT: {{ matrix.dp_variant }} + DP_VARIANT: ${{ matrix.dp_variant }} - uses: actions/upload-artifact@v2 with: path: ./wheelhouse/*.whl From e3cfeb6e3e31362b00c77d908f8c308277d23ac3 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 13 Dec 2022 00:50:31 -0500 Subject: [PATCH 6/9] fix sh --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b605a18a18..d5201af676 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,7 @@ repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest repair-wheel-command = "auditwheel repair --exclude libtensorflow_framework.so.2 --exclude libtensorflow_framework.so.1 --exclude libtensorflow_framework.so -w {dest_dir} {wheel}" environment-pass = ["CIBW_BUILD", "DP_VARIANT"] before-all = """ -if [ "$(uname -m)" == "x86_64" ] then +if [ "$(uname -m)" = "x86_64" ]; then yum config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo && yum install -y cuda-11-8 fi """ From 8b4cb621474a8332745e57498200d8f8a9c79b16 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 13 Dec 2022 01:14:03 -0500 Subject: [PATCH 7/9] fix requirements --- backend/find_tensorflow.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/find_tensorflow.py b/backend/find_tensorflow.py index 74b50d40a0..2ff499d6c1 100644 --- a/backend/find_tensorflow.py +++ b/backend/find_tensorflow.py @@ -1,5 +1,6 @@ import site import os +import platform from importlib.util import find_spec from importlib.machinery import FileFinder from sysconfig import get_path @@ -85,8 +86,19 @@ def get_tf_requirement(tf_version: str = "") -> dict: """ if tf_version == "": tf_version = os.environ.get("TENSORFLOW_VERSION", "") + machine = platform.uname().machine - if tf_version == "": + if machine == 'aarch64' and tf_version == "": + return { + "cpu": ["tensorflow"], + "gpu": ["tensorflow"], + } + elif machine == 'aarch64': + return { + "cpu": ["tensorflow=={tf_version}"], + "gpu": ["tensorflow=={tf_version}"], + } + elif tf_version == "": return { "cpu": ["tensorflow-cpu"], "gpu": ["tensorflow"], From c709f1252fe4c86110983d036ebe5a4fd2a44851 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Fri, 16 Dec 2022 18:03:47 -0500 Subject: [PATCH 8/9] use PEP508 tags Signed-off-by: Jinzhe Zeng --- backend/find_tensorflow.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/backend/find_tensorflow.py b/backend/find_tensorflow.py index 2ff499d6c1..0c9ff026b7 100644 --- a/backend/find_tensorflow.py +++ b/backend/find_tensorflow.py @@ -1,6 +1,5 @@ import site import os -import platform from importlib.util import find_spec from importlib.machinery import FileFinder from sysconfig import get_path @@ -86,32 +85,21 @@ def get_tf_requirement(tf_version: str = "") -> dict: """ if tf_version == "": tf_version = os.environ.get("TENSORFLOW_VERSION", "") - machine = platform.uname().machine - if machine == 'aarch64' and tf_version == "": - return { - "cpu": ["tensorflow"], - "gpu": ["tensorflow"], - } - elif machine == 'aarch64': - return { - "cpu": ["tensorflow=={tf_version}"], - "gpu": ["tensorflow=={tf_version}"], - } - elif tf_version == "": + if tf_version == "": return { - "cpu": ["tensorflow-cpu"], - "gpu": ["tensorflow"], + "cpu": ["tensorflow-cpu; platform_machine!='aarch64'", f"tensorflow; platform_machine=='aarch64'"], + "gpu": ["tensorflow; platform_machine!='aarch64'", f"tensorflow; platform_machine=='aarch64'"], } elif tf_version in SpecifierSet("<1.15") or tf_version in SpecifierSet(">=2.0,<2.1"): return { - "cpu": [f"tensorflow=={tf_version}"], - "gpu": [f"tensorflow-gpu=={tf_version}"], + "cpu": [f"tensorflow=={tf_version}; platform_machine!='aarch64'", f"tensorflow=={tf_version}; platform_machine=='aarch64'"], + "gpu": [f"tensorflow-gpu=={tf_version}; platform_machine!='aarch64'", f"tensorflow=={tf_version}; platform_machine=='aarch64'"], } else: return { - "cpu": [f"tensorflow-cpu=={tf_version}"], - "gpu": [f"tensorflow=={tf_version}"], + "cpu": [f"tensorflow-cpu=={tf_version}; platform_machine!='aarch64'", f"tensorflow=={tf_version}; platform_machine=='aarch64'"], + "gpu": [f"tensorflow=={tf_version}; platform_machine!='aarch64'", f"tensorflow=={tf_version}; platform_machine=='aarch64'"], } From 4395852790b1a3f2955a204c3698191fd4eec693 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Fri, 16 Dec 2022 18:04:14 -0500 Subject: [PATCH 9/9] Update find_tensorflow.py Signed-off-by: Jinzhe Zeng --- backend/find_tensorflow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/find_tensorflow.py b/backend/find_tensorflow.py index 0c9ff026b7..d0998d0460 100644 --- a/backend/find_tensorflow.py +++ b/backend/find_tensorflow.py @@ -88,8 +88,8 @@ def get_tf_requirement(tf_version: str = "") -> dict: if tf_version == "": return { - "cpu": ["tensorflow-cpu; platform_machine!='aarch64'", f"tensorflow; platform_machine=='aarch64'"], - "gpu": ["tensorflow; platform_machine!='aarch64'", f"tensorflow; platform_machine=='aarch64'"], + "cpu": ["tensorflow-cpu; platform_machine!='aarch64'", "tensorflow; platform_machine=='aarch64'"], + "gpu": ["tensorflow; platform_machine!='aarch64'", "tensorflow; platform_machine=='aarch64'"], } elif tf_version in SpecifierSet("<1.15") or tf_version in SpecifierSet(">=2.0,<2.1"): return {