2
2
3
3
# This script is for building AARCH64 wheels using AWS EC2 instances.
4
4
# To generate binaries for the release follow these steps:
5
- # 1. Update mappings for each of the Domain Libraries by adding new row to a table like this: "v1.11.0": ("0.11.0", "rc1"),
6
- # 2. Run script with following arguments for each of the supported python versions and specify required RC tag for example: v1.11.0-rc3:
7
- # build_aarch64_wheel.py --key-name <YourPemKey> --use-docker --python 3.8 --branch <RCtag>
5
+ # 1. Update mappings for each of the Domain Libraries by adding new row to a table like this:
6
+ # "v1.11.0": ("0.11.0", "rc1"),
7
+ # 2. Run script with following arguments for each of the supported python versions and required tag, for example:
8
+ # build_aarch64_wheel.py --key-name <YourPemKey> --use-docker --python 3.8 --branch v1.11.0-rc3
8
9
9
10
10
11
import boto3
@@ -177,7 +178,7 @@ def wait_for_connection(addr, port, timeout=15, attempt_cnt=5):
177
178
try :
178
179
with socket .create_connection ((addr , port ), timeout = timeout ):
179
180
return
180
- except (ConnectionRefusedError , socket .timeout ):
181
+ except (ConnectionRefusedError , socket .timeout ): # noqa: PERF203
181
182
if i == attempt_cnt - 1 :
182
183
raise
183
184
time .sleep (timeout )
@@ -203,7 +204,7 @@ def install_condaforge(host: RemoteHost,
203
204
if host .using_docker ():
204
205
host .run_cmd ("echo 'PATH=$HOME/miniforge3/bin:$PATH'>>.bashrc" )
205
206
else :
206
- host .run_cmd (['sed' , '-i' , '\' /^# If not running interactively.*/i PATH=$HOME/miniforge3/bin:$PATH\' ' , '.bashrc' ])
207
+ host .run_cmd (['sed' , '-i' , '\' /^# If not running interactively.*/i PATH=$HOME/miniforge3/bin:$PATH\' ' , '.bashrc' ]) # noqa: E501
207
208
208
209
209
210
def install_condaforge_python (host : RemoteHost , python_version = "3.8" ) -> None :
@@ -221,12 +222,13 @@ def build_OpenBLAS(host: RemoteHost, git_clone_flags: str = "") -> None:
221
222
print ('Building OpenBLAS' )
222
223
host .run_cmd (f"git clone https://github.com/xianyi/OpenBLAS -b v0.3.25 { git_clone_flags } " )
223
224
make_flags = "NUM_THREADS=64 USE_OPENMP=1 NO_SHARED=1 DYNAMIC_ARCH=1 TARGET=ARMV8"
224
- host .run_cmd (f"pushd OpenBLAS && make { make_flags } -j8 && sudo make { make_flags } install && popd && rm -rf OpenBLAS" )
225
+ host .run_cmd (f"pushd OpenBLAS && make { make_flags } -j8 && sudo make { make_flags } install && popd && rm -rf OpenBLAS" ) # noqa: E501
225
226
226
227
227
228
def build_ArmComputeLibrary (host : RemoteHost , git_clone_flags : str = "" ) -> None :
228
229
print ('Building Arm Compute Library' )
229
- acl_build_flags = "debug=0 neon=1 opencl=0 os=linux openmp=1 cppthreads=0 arch=armv8a multi_isa=1 fixed_format_kernels=1 build=native"
230
+ acl_build_flags = " " .join (["debug=0" , "neon=1" , "opencl=0" , "os=linux" , "openmp=1" , "cppthreads=0" ,
231
+ "arch=armv8a" , "multi_isa=1" , "fixed_format_kernels=1" , "build=native" ])
230
232
host .run_cmd (f"git clone https://github.com/ARM-software/ComputeLibrary.git -b v23.08 { git_clone_flags } " )
231
233
host .run_cmd (f"cd ComputeLibrary && scons Werror=1 -j8 { acl_build_flags } " )
232
234
@@ -301,7 +303,7 @@ def build_torchvision(host: RemoteHost, *,
301
303
# Remove .so files to force static linking
302
304
host .run_cmd ("rm miniforge3/lib/libpng.so miniforge3/lib/libpng16.so miniforge3/lib/libjpeg.so" )
303
305
# And patch setup.py to include libz dependency for libpng
304
- host .run_cmd (['sed -i -e \' s/image_link_flags\.append("png")/image_link_flags += ["png", "z"]/\' vision/setup.py' ])
306
+ host .run_cmd (['sed -i -e \' s/image_link_flags\\ .append("png")/image_link_flags += ["png", "z"]/\' vision/setup.py' ]) # noqa: E501
305
307
306
308
build_vars = ""
307
309
if branch == "nightly" :
@@ -525,7 +527,7 @@ def start_build(host: RemoteHost, *,
525
527
if host .using_docker ():
526
528
print ("Move libgfortant.a into a standard location" )
527
529
# HACK: pypa gforntran.a is compiled without PIC, which leads to the following error
528
- # libgfortran.a(error.o)(.text._gfortrani_st_printf+0x34): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `__stack_chk_guard@@GLIBC_2.17'
530
+ # libgfortran.a(error.o)(.text._gfortrani_st_printf+0x34): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `__stack_chk_guard@@GLIBC_2.17' # noqa: E501
529
531
# Workaround by copying gfortran library from the host
530
532
host .run_ssh_cmd ("sudo apt-get install -y gfortran-8" )
531
533
host .run_cmd ("mkdir -p /usr/lib/gcc/aarch64-linux-gnu/8" )
@@ -543,22 +545,23 @@ def start_build(host: RemoteHost, *,
543
545
# Breakpad build fails on aarch64
544
546
build_vars = "USE_BREAKPAD=0 "
545
547
if branch == 'nightly' :
546
- build_date = host .check_output ("cd pytorch && git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" )
548
+ build_date = host .check_output ("cd pytorch && git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" ) # noqa: E501
547
549
version = host .check_output ("cat pytorch/version.txt" ).strip ()[:- 2 ]
548
550
build_vars += f"BUILD_TEST=0 PYTORCH_BUILD_VERSION={ version } .dev{ build_date } PYTORCH_BUILD_NUMBER=1"
549
- if branch .startswith ("v1." ) or branch . startswith ( "v2." ):
551
+ if branch .startswith (( "v1." , "v2." ) ):
550
552
build_vars += f"BUILD_TEST=0 PYTORCH_BUILD_VERSION={ branch [1 :branch .find ('-' )]} PYTORCH_BUILD_NUMBER=1"
551
553
if host .using_docker ():
552
554
build_vars += " CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000"
553
555
if enable_mkldnn :
554
556
build_ArmComputeLibrary (host , git_clone_flags )
555
557
print ("build pytorch with mkldnn+acl backend" )
556
558
build_vars += " USE_MKLDNN=ON USE_MKLDNN_ACL=ON"
557
- host .run_cmd (f"cd $HOME && git clone https://github.com/pytorch/builder.git" )
558
- host .run_cmd (f"cd $HOME/pytorch && export ACL_ROOT_DIR=$HOME/ComputeLibrary && { build_vars } python3 setup.py bdist_wheel{ build_opts } " )
559
+ host .run_cmd ("cd $HOME && git clone https://github.com/pytorch/builder.git && cd builder && git checkout release/2.2" ) # noqa: E501
560
+ host .run_cmd ("cd $HOME/pytorch/third_party/ideep/mkl-dnn && patch -p1 < $HOME/builder/mkldnn_fix/fix-xbyak-failure.patch" ) # noqa: E501
561
+ host .run_cmd (f"cd $HOME/pytorch && export ACL_ROOT_DIR=$HOME/ComputeLibrary && { build_vars } python3 setup.py bdist_wheel{ build_opts } " ) # noqa: E501
559
562
print ('Repair the wheel' )
560
563
pytorch_wheel_name = host .list_dir ("pytorch/dist" )[0 ]
561
- host .run_cmd (f"export LD_LIBRARY_PATH=$HOME/acl/build:$HOME/pytorch/build/lib && auditwheel repair $HOME/pytorch/dist/{ pytorch_wheel_name } " )
564
+ host .run_cmd (f"export LD_LIBRARY_PATH=$HOME/acl/build:$HOME/pytorch/build/lib && auditwheel repair $HOME/pytorch/dist/{ pytorch_wheel_name } " ) # noqa: E501
562
565
print ('replace the original wheel with the repaired one' )
563
566
pytorch_repaired_wheel_name = host .list_dir ("wheelhouse" )[0 ]
564
567
host .run_cmd (f"cp $HOME/wheelhouse/{ pytorch_repaired_wheel_name } $HOME/pytorch/dist/{ pytorch_wheel_name } " )
@@ -706,7 +709,7 @@ def parse_arguments():
706
709
parser .add_argument ("--build-only" , action = "store_true" )
707
710
parser .add_argument ("--test-only" , type = str )
708
711
parser .add_argument ("--os" , type = str , choices = list (os_amis .keys ()), default = 'ubuntu20_04' )
709
- parser .add_argument ("--python-version" , type = str , choices = ['3.6' , '3.7' , '3.8' , '3.9' , '3.10' , '3.11' ], default = None )
712
+ parser .add_argument ("--python-version" , type = str , choices = [f '3.{ d } ' for d in range ( 6 , 12 ) ], default = None )
710
713
parser .add_argument ("--alloc-instance" , action = "store_true" )
711
714
parser .add_argument ("--list-instances" , action = "store_true" )
712
715
parser .add_argument ("--pytorch-only" , action = "store_true" )
0 commit comments