Skip to content

Commit ba10bae

Browse files
authored
aarch64: cd: switch from libomp to libgomp (#1805)
In the current version of the CD scripts, torch libraries are linked to llvm openmp because conda openblas-openmp is linked to it. To switch to gnu libgomp, we are building the openblas from sources instead of installing from conda. Building openBLAS shared library instead of static library to be able to discover LAPACK support in OpenBLAS. cherrypicked from #1803 fixes: #1774
1 parent e5d769d commit ba10bae

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

aarch64_linux/aarch64_ci_setup.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if [[ "$DESIRED_PYTHON" == "3.8" ]]; then
3030
else
3131
pip install -q --pre numpy==2.0.0rc1
3232
fi
33-
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
33+
conda install -y -c conda-forge pyyaml==6.0.1 patchelf==0.17.2 pygit2==1.13.2 ninja==1.11.1 scons==4.5.2
3434

3535
python --version
3636
conda --version

aarch64_linux/aarch64_wheel_ci_build.py

+41-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,43 @@ def list_dir(path: str) -> List[str]:
1515
return check_output(["ls", "-1", path]).decode().split("\n")
1616

1717

18+
def build_OpenBLAS() -> None:
19+
'''
20+
Building OpenBLAS, because the package in many linux is old
21+
'''
22+
print('Building OpenBLAS')
23+
openblas_build_flags = [
24+
"NUM_THREADS=128",
25+
"USE_OPENMP=1",
26+
"NO_SHARED=0",
27+
"DYNAMIC_ARCH=1",
28+
"TARGET=ARMV8",
29+
"CFLAGS=-O3",
30+
]
31+
openblas_checkout_dir = "OpenBLAS"
32+
33+
check_call(
34+
[
35+
"git",
36+
"clone",
37+
"https://github.com/OpenMathLib/OpenBLAS.git",
38+
"-b",
39+
"v0.3.25",
40+
"--depth",
41+
"1",
42+
"--shallow-submodules",
43+
]
44+
)
45+
46+
check_call(["make", "-j8"]
47+
+ openblas_build_flags,
48+
cwd=openblas_checkout_dir)
49+
check_call(["make", "-j8"]
50+
+ openblas_build_flags
51+
+ ["install"],
52+
cwd=openblas_checkout_dir)
53+
54+
1855
def build_ArmComputeLibrary() -> None:
1956
'''
2057
Using ArmComputeLibrary for aarch64 PyTorch
@@ -95,14 +132,17 @@ def parse_arguments():
95132
elif branch.startswith(("v1.", "v2.")):
96133
build_vars += f"BUILD_TEST=0 PYTORCH_BUILD_VERSION={branch[1:branch.find('-')]} PYTORCH_BUILD_NUMBER=1 "
97134

135+
build_OpenBLAS()
98136
if enable_mkldnn:
99137
build_ArmComputeLibrary()
100138
print("build pytorch with mkldnn+acl backend")
101139
build_vars += "USE_MKLDNN=ON USE_MKLDNN_ACL=ON " \
102140
"ACL_ROOT_DIR=/acl " \
103141
"LD_LIBRARY_PATH=/pytorch/build/lib:/acl/build:$LD_LIBRARY_PATH " \
104142
"ACL_INCLUDE_DIR=/acl/build " \
105-
"ACL_LIBRARY=/acl/build "
143+
"ACL_LIBRARY=/acl/build " \
144+
"BLAS=OpenBLAS " \
145+
"OpenBLAS_HOME=/OpenBLAS "
106146
else:
107147
print("build pytorch without mkldnn backend")
108148

0 commit comments

Comments
 (0)