Skip to content

Commit

Permalink
aarch64: cd: upgrade to manylinux 2_28 and remove conda dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
snadampal committed Apr 10, 2024
1 parent ef4a28a commit 2fa4a66
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 30 deletions.
66 changes: 38 additions & 28 deletions aarch64_linux/aarch64_ci_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,45 @@
set -eux -o pipefail

# This script is used to prepare the Docker container for aarch64_ci_wheel_build.py python script
# as we need to install conda and setup the python version for the build.

CONDA_PYTHON_EXE=/opt/conda/bin/python
CONDA_EXE=/opt/conda/bin/conda
CONDA_ENV_NAME=aarch64_env
PATH=/opt/conda/bin:$PATH
LD_LIBRARY_PATH=/opt/conda/envs/${CONDA_ENV_NAME}/lib/:/opt/conda/lib:$LD_LIBRARY_PATH

###############################################################################
# Install conda
# disable SSL_verify due to getting "Could not find a suitable TLS CA certificate bundle, invalid path"
# when using Python version, less than the conda latest
###############################################################################
echo 'Installing conda-forge'
curl -L -o /mambaforge.sh https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh
chmod +x /mambaforge.sh
/mambaforge.sh -b -p /opt/conda
rm /mambaforge.sh
source /opt/conda/etc/profile.d/conda.sh
conda config --set ssl_verify False
conda create -y -c conda-forge -n "${CONDA_ENV_NAME}" python=${DESIRED_PYTHON}
conda activate "${CONDA_ENV_NAME}"
# as we need to setup the required python version and install few tools.

if [[ "$DESIRED_PYTHON" == "3.8" ]]; then
pip install -q numpy==1.24.4
dnf update

if [ "$DESIRED_PYTHON" == "3.8" ] || [ "$DESIRED_PYTHON" == "3.9" ] || [ "$DESIRED_PYTHON" == "3.11" ]; then
dnf install -y python$DESIRED_PYTHON

elif [ "$DESIRED_PYTHON" == "3.10" ] || [ "$DESIRED_PYTHON" == "3.12" ]; then
dnf install -y epel-release
dnf install -y gcc openssl-devel bzip2-devel libffi-devel zlib-devel wget make
if [ "$DESIRED_PYTHON" == "3.10" ]; then
PYTHON_INSTALLED_VERSION="3.10.14"
else
PYTHON_INSTALLED_VERSION="3.12.3"
fi
wget https://www.python.org/ftp/python/${PYTHON_INSTALLED_VERSION}/Python-${PYTHON_INSTALLED_VERSION}.tgz
tar xzf Python-${PYTHON_INSTALLED_VERSION}.tgz
cd Python-${PYTHON_INSTALLED_VERSION}
./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions
make -j 8
make altinstall
cd ..
rm Python-${PYTHON_INSTALLED_VERSION}.tgz
else
pip install -q --pre numpy==2.0.0rc1
echo "unsupported python version passed. 3.8, 3.9, 3.10 or 3.11 are the only supported versions"
exit 1
fi
conda install -y -c conda-forge pyyaml==6.0.1 patchelf==0.17.2 pygit2==1.13.2 openblas==0.3.25=*openmp* ninja==1.11.1 scons==4.5.2

python --version
conda --version
/usr/local/bin/python${DESIRED_PYTHON} -m venv appenv${DESIRED_PYTHON}

source appenv${DESIRED_PYTHON}/bin/activate

python3 --version

dnf install -y python3-devel python3-pip

python3 -m pip install dataclasses typing-extensions scons pyyaml pygit2 ninja patchelf Cython
if [[ "$DESIRED_PYTHON" == "3.8" ]]; then
python3 -m pip install -q numpy==1.24.4
else
python3 -m pip install -q --pre numpy==2.0.0rc1
fi
22 changes: 20 additions & 2 deletions aarch64_linux/aarch64_wheel_ci_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ def list_dir(path: str) -> List[str]:
return check_output(["ls", "-1", path]).decode().split("\n")


def build_OpenBLAS() -> None:
'''
Building OpenBLAS, because the package in many linux is old
'''
print('Building OpenBLAS')
openblas_build_flags=["NUM_THREADS=128", "USE_OPENMP=1", "DYNAMIC_ARCH=1", "TARGET=ARMV8", "CFLAGS=-O3"]
openblas_checkout_dir="OpenBLAS"

check_call(["git", "clone", "https://github.com/OpenMathLib/OpenBLAS.git", "-b", "v0.3.25",
"--depth", "1", "--shallow-submodules"])

check_call(["make", "-j8"] + openblas_build_flags,
cwd=openblas_checkout_dir)
check_call(["make", "-j8"] + openblas_build_flags + ["install"], cwd=openblas_checkout_dir)

def build_ArmComputeLibrary() -> None:
'''
Using ArmComputeLibrary for aarch64 PyTorch
Expand All @@ -27,7 +42,7 @@ def build_ArmComputeLibrary() -> None:
os.makedirs(acl_install_dir)
check_call(["git", "clone", "https://github.com/ARM-software/ComputeLibrary.git", "-b", "v23.08",
"--depth", "1", "--shallow-submodules"])
check_call(["scons", "Werror=1", "-j8", f"build_dir=/{acl_install_dir}/build"] + acl_build_flags,
check_call(["scons", "Werror=0", "-j8", f"build_dir=/{acl_install_dir}/build"] + acl_build_flags,
cwd=acl_checkout_dir)
for d in ["arm_compute", "include", "utils", "support", "src"]:
shutil.copytree(f"{acl_checkout_dir}/{d}", f"{acl_install_dir}/{d}")
Expand Down Expand Up @@ -95,14 +110,17 @@ def parse_arguments():
elif branch.startswith(("v1.", "v2.")):
build_vars += f"BUILD_TEST=0 PYTORCH_BUILD_VERSION={branch[1:branch.find('-')]} PYTORCH_BUILD_NUMBER=1 "

build_OpenBLAS()
if enable_mkldnn:
build_ArmComputeLibrary()
print("build pytorch with mkldnn+acl backend")
build_vars += "USE_MKLDNN=ON USE_MKLDNN_ACL=ON " \
"ACL_ROOT_DIR=/acl " \
"LD_LIBRARY_PATH=/pytorch/build/lib:/acl/build:$LD_LIBRARY_PATH " \
"ACL_INCLUDE_DIR=/acl/build " \
"ACL_LIBRARY=/acl/build "
"ACL_LIBRARY=/acl/build " \
"BLAS=OpenBLAS " \
"OpenBLAS_HOME=/OpenBLAS "
else:
print("build pytorch without mkldnn backend")

Expand Down

0 comments on commit 2fa4a66

Please sign in to comment.