Skip to content

Commit 02ed62c

Browse files
atalmansnadampal
andauthored
[aarch64] Fix for pytorch-2.1.0 aarch64 wheels crash on A1/Raspberry Pie (#1562)
* [aarch64] set acl_build_flags arch=armv8a, remove editing build flags (#1550) Looking at this PR: #1370 this line: https://github.com/pytorch/builder/pull/1370/files#diff-54480d0a69ca27f54fb0736a9762caa8b03bd4736dcd77190d99ec3033c9bd2fR229 That fixed the issue: pytorch/pytorch#97226 One of the changes is to set ``` arch=armv8a ``` We are experiencing the same issue now: pytorch/pytorch#109312 Hence this fix. * [aarch64] patch mkl-dnn to use 'march=armv8-a' as the default build (#1554) * [aarch64] patch pytorch 2.1 for mkl-dnn fix (#1555) * patch ci script with mkldnn fix (#1556) * Fix path issue when building aarch64 wheels (#1560) --------- Co-authored-by: snadampal <[email protected]>
1 parent 01ce69f commit 02ed62c

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

aarch64_linux/aarch64_wheel_ci_build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ def build_ArmComputeLibrary(git_clone_flags: str = "") -> None:
2121
print('Building Arm Compute Library')
2222
os.system("cd / && mkdir /acl")
2323
os.system(f"git clone https://github.com/ARM-software/ComputeLibrary.git -b v23.05.1 {git_clone_flags}")
24-
os.system('sed -i -e \'s/"armv8.2-a"/"armv8-a"/g\' ComputeLibrary/SConscript; '
25-
'sed -i -e \'s/-march=armv8.2-a+fp16/-march=armv8-a/g\' ComputeLibrary/SConstruct; '
26-
'sed -i -e \'s/"-march=armv8.2-a"/"-march=armv8-a"/g\' ComputeLibrary/filedefs.json')
2724
os.system("cd ComputeLibrary; export acl_install_dir=/acl; "
28-
"scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux openmp=1 cppthreads=0 arch=armv8.2-a multi_isa=1 build=native build_dir=$acl_install_dir/build; "
25+
"scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux openmp=1 cppthreads=0 arch=armv8a multi_isa=1 build=native build_dir=$acl_install_dir/build; "
2926
"cp -r arm_compute $acl_install_dir; "
3027
"cp -r include $acl_install_dir; "
3128
"cp -r utils $acl_install_dir; "
@@ -108,6 +105,9 @@ def parse_arguments():
108105
else:
109106
print("build pytorch without mkldnn backend")
110107

108+
# work around to fix Raspberry pie crash
109+
print("Applying mkl-dnn patch to fix Raspberry pie crash")
110+
os.system(f"cd /pytorch/third_party/ideep/mkl-dnn && patch -p1 < /builder/mkldnn_fix/aarch64-fix-default-build-flags-to-armv8-a.patch")
111111
os.system(f"cd /pytorch; {build_vars} python3 setup.py bdist_wheel")
112112
pytorch_wheel_name = complete_wheel("pytorch")
113113
print(f"Build Compelete. Created {pytorch_wheel_name}..")

aarch64_linux/build_aarch64_wheel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,9 @@ def start_build(host: RemoteHost, *,
557557
build_ArmComputeLibrary(host, git_clone_flags)
558558
print("build pytorch with mkldnn+acl backend")
559559
build_vars += " USE_MKLDNN=ON USE_MKLDNN_ACL=ON"
560-
host.run_cmd(f"cd pytorch && export ACL_ROOT_DIR=$HOME/ComputeLibrary && {build_vars} python3 setup.py bdist_wheel{build_opts}")
560+
host.run_cmd(f"cd $HOME && git clone https://github.com/pytorch/builder.git")
561+
host.run_cmd(f"cd $HOME/pytorch/third_party/ideep/mkl-dnn && patch -p1 < $HOME/builder/mkldnn_fix/aarch64-fix-default-build-flags-to-armv8-a.patch")
562+
host.run_cmd(f"cd $HOME/pytorch && export ACL_ROOT_DIR=$HOME/ComputeLibrary && {build_vars} python3 setup.py bdist_wheel{build_opts}")
561563
print('Repair the wheel')
562564
pytorch_wheel_name = host.list_dir("pytorch/dist")[0]
563565
host.run_cmd(f"export LD_LIBRARY_PATH=$HOME/acl/build:$HOME/pytorch/build/lib && auditwheel repair $HOME/pytorch/dist/{pytorch_wheel_name}")
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
cmake/platform.cmake | 4 ++--
3+
1 file changed, 2 insertions(+), 2 deletions(-)
4+
5+
diff --git a/cmake/platform.cmake b/cmake/platform.cmake
6+
index 8630460ce..602eafe8e 100644
7+
--- a/cmake/platform.cmake
8+
+++ b/cmake/platform.cmake
9+
@@ -198,7 +198,7 @@ elseif(UNIX OR MINGW)
10+
endif()
11+
# For native compilation tune for the host processor
12+
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
13+
- append(DEF_ARCH_OPT_FLAGS "-mcpu=native")
14+
+ append(DEF_ARCH_OPT_FLAGS "-march=armv8-a")
15+
endif()
16+
elseif(DNNL_TARGET_ARCH STREQUAL "PPC64")
17+
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
18+
@@ -295,7 +295,7 @@ elseif(UNIX OR MINGW)
19+
endif()
20+
# For native compilation tune for the host processor
21+
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
22+
- append(DEF_ARCH_OPT_FLAGS "-mcpu=native")
23+
+ append(DEF_ARCH_OPT_FLAGS "-march=armv8-a")
24+
endif()
25+
elseif(DNNL_TARGET_ARCH STREQUAL "PPC64")
26+
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
27+
--
28+
2.34.1
29+

0 commit comments

Comments
 (0)