@@ -128,7 +128,7 @@ def run_cmd(self, args: Union[str, List[str]]) -> None:
128
128
assert self .container_id is not None
129
129
docker_cmd = self ._gen_ssh_prefix () + ['docker' , 'exec' , '-i' , self .container_id , 'bash' ]
130
130
p = subprocess .Popen (docker_cmd , stdin = subprocess .PIPE )
131
- p .communicate (input = " " .join (["source .bashrc; " ] + self ._split_cmd (args )).encode ("utf-8" ))
131
+ p .communicate (input = " " .join (["source .bashrc && " ] + self ._split_cmd (args )).encode ("utf-8" ))
132
132
rc = p .wait ()
133
133
if rc != 0 :
134
134
raise subprocess .CalledProcessError (rc , docker_cmd )
@@ -139,7 +139,7 @@ def check_output(self, args: Union[str, List[str]]) -> str:
139
139
assert self .container_id is not None
140
140
docker_cmd = self ._gen_ssh_prefix () + ['docker' , 'exec' , '-i' , self .container_id , 'bash' ]
141
141
p = subprocess .Popen (docker_cmd , stdin = subprocess .PIPE , stdout = subprocess .PIPE )
142
- (out , err ) = p .communicate (input = " " .join (["source .bashrc; " ] + self ._split_cmd (args )).encode ("utf-8" ))
142
+ (out , err ) = p .communicate (input = " " .join (["source .bashrc && " ] + self ._split_cmd (args )).encode ("utf-8" ))
143
143
rc = p .wait ()
144
144
if rc != 0 :
145
145
raise subprocess .CalledProcessError (rc , docker_cmd , output = out , stderr = err )
@@ -225,23 +225,16 @@ def build_OpenBLAS(host: RemoteHost, git_clone_flags: str = "") -> None:
225
225
print ('Building OpenBLAS' )
226
226
host .run_cmd (f"git clone https://github.com/xianyi/OpenBLAS -b v0.3.19 { git_clone_flags } " )
227
227
make_flags = "NUM_THREADS=64 USE_OPENMP=1 NO_SHARED=1 DYNAMIC_ARCH=1 TARGET=ARMV8"
228
- host .run_cmd (f"pushd OpenBLAS; make { make_flags } -j8; sudo make { make_flags } install; popd; rm -rf OpenBLAS" )
228
+ host .run_cmd (f"pushd OpenBLAS && make { make_flags } -j8 && sudo make { make_flags } install && popd && rm -rf OpenBLAS" )
229
229
230
230
231
231
def build_ArmComputeLibrary (host : RemoteHost , git_clone_flags : str = "" ) -> None :
232
232
print ('Building Arm Compute Library' )
233
- host .run_cmd ("mkdir $HOME/acl" )
233
+ acl_install_dir = "${HOME}/acl"
234
+ acl_build_flags = "debug=0 neon=1 opencl=0 os=linux openmp=1 cppthreads=0 arch=armv8.2-a multi_isa=1 build=native"
235
+ host .run_cmd (f"mkdir { acl_install_dir } " )
234
236
host .run_cmd (f"git clone https://github.com/ARM-software/ComputeLibrary.git -b v22.11 { git_clone_flags } " )
235
- host .run_cmd ("pushd ComputeLibrary; export acl_install_dir=$HOME/acl; 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; cp -r arm_compute $acl_install_dir; cp -r include $acl_install_dir; cp -r utils $acl_install_dir; cp -r support $acl_install_dir; popd" )
236
-
237
-
238
- def build_FFTW (host : RemoteHost , git_clone_flags : str = "" ) -> None :
239
- print ("Building FFTW3" )
240
- host .run_cmd ("sudo apt-get install -y ocaml ocamlbuild autoconf automake indent libtool fig2dev texinfo" )
241
- # TODO: fix a version to build
242
- # TODO: consider adding flags --host=arm-linux-gnueabi --enable-single --enable-neon CC=arm-linux-gnueabi-gcc -march=armv7-a -mfloat-abi=softfp
243
- host .run_cmd (f"git clone https://github.com/FFTW/fftw3 { git_clone_flags } " )
244
- host .run_cmd ("pushd fftw3; sh bootstrap.sh; make -j8; sudo make install; popd" )
237
+ host .run_cmd (f"cd ComputeLibrary && scons Werror=1 -j8 { acl_build_flags } build_dir={ acl_install_dir } /build" )
245
238
246
239
247
240
def embed_libgomp (host : RemoteHost , use_conda , wheel_name ) -> None :
@@ -261,7 +254,7 @@ def embed_libgomp(host: RemoteHost, use_conda, wheel_name) -> None:
261
254
262
255
263
256
def checkout_repo (host : RemoteHost , * ,
264
- branch : str = "master " ,
257
+ branch : str = "main " ,
265
258
url : str ,
266
259
git_clone_flags : str ,
267
260
mapping : Dict [str , Tuple [str , str ]]) -> Optional [str ]:
@@ -272,12 +265,16 @@ def checkout_repo(host: RemoteHost, *,
272
265
host .run_cmd (f"git clone { url } -b { tag } { git_clone_flags } " )
273
266
return mapping [prefix ][0 ]
274
267
275
- host .run_cmd (f"git clone { url } { git_clone_flags } " )
268
+ # Map master to main
269
+ if branch == "master" and url .rsplit ("/" )[- 1 ] in ['vision' , 'text' , 'audio' , 'data' ]:
270
+ branch = "main"
271
+
272
+ host .run_cmd (f"git clone { url } -b { branch } { git_clone_flags } " )
276
273
return None
277
274
278
275
279
276
def build_torchvision (host : RemoteHost , * ,
280
- branch : str = "master " ,
277
+ branch : str = "main " ,
281
278
use_conda : bool = True ,
282
279
git_clone_flags : str ,
283
280
run_smoke_tests : bool = True ) -> str :
@@ -317,14 +314,14 @@ def build_torchvision(host: RemoteHost, *,
317
314
if len (version ) == 0 :
318
315
# In older revisions, version was embedded in setup.py
319
316
version = host .check_output (["grep" , "\" version = '\" " , "vision/setup.py" ]).strip ().split ("'" )[1 ][:- 2 ]
320
- build_date = host .check_output ("cd pytorch ; git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" )
317
+ build_date = host .check_output ("cd vision && git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" )
321
318
build_vars += f"BUILD_VERSION={ version } .dev{ build_date } "
322
319
elif build_version is not None :
323
320
build_vars += f"BUILD_VERSION={ build_version } PYTORCH_VERSION={ branch [1 :].split ('-' )[0 ]} "
324
321
if host .using_docker ():
325
322
build_vars += " CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000"
326
323
327
- host .run_cmd (f"cd vision; { build_vars } python3 setup.py bdist_wheel" )
324
+ host .run_cmd (f"cd vision && { build_vars } python3 setup.py bdist_wheel" )
328
325
vision_wheel_name = host .list_dir ("vision/dist" )[0 ]
329
326
embed_libgomp (host , use_conda , os .path .join ('vision' , 'dist' , vision_wheel_name ))
330
327
@@ -357,14 +354,14 @@ def build_torchdata(host: RemoteHost, *,
357
354
build_vars = ""
358
355
if branch == 'nightly' :
359
356
version = host .check_output (["if [ -f data/version.txt ]; then cat data/version.txt; fi" ]).strip ()
360
- build_date = host .check_output ("cd pytorch ; git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" )
357
+ build_date = host .check_output ("cd data && git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" )
361
358
build_vars += f"BUILD_VERSION={ version } .dev{ build_date } "
362
359
elif build_version is not None :
363
360
build_vars += f"BUILD_VERSION={ build_version } PYTORCH_VERSION={ branch [1 :].split ('-' )[0 ]} "
364
361
if host .using_docker ():
365
362
build_vars += " CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000"
366
363
367
- host .run_cmd (f"cd data; { build_vars } python3 setup.py bdist_wheel" )
364
+ host .run_cmd (f"cd data && { build_vars } python3 setup.py bdist_wheel" )
368
365
wheel_name = host .list_dir ("data/dist" )[0 ]
369
366
embed_libgomp (host , use_conda , os .path .join ('data' , 'dist' , wheel_name ))
370
367
@@ -400,14 +397,14 @@ def build_torchtext(host: RemoteHost, *,
400
397
build_vars = ""
401
398
if branch == 'nightly' :
402
399
version = host .check_output (["if [ -f text/version.txt ]; then cat text/version.txt; fi" ]).strip ()
403
- build_date = host .check_output ("cd pytorch ; git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" )
400
+ build_date = host .check_output ("cd text && git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" )
404
401
build_vars += f"BUILD_VERSION={ version } .dev{ build_date } "
405
402
elif build_version is not None :
406
403
build_vars += f"BUILD_VERSION={ build_version } PYTORCH_VERSION={ branch [1 :].split ('-' )[0 ]} "
407
404
if host .using_docker ():
408
405
build_vars += " CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000"
409
406
410
- host .run_cmd (f"cd text; { build_vars } python3 setup.py bdist_wheel" )
407
+ host .run_cmd (f"cd text && { build_vars } python3 setup.py bdist_wheel" )
411
408
wheel_name = host .list_dir ("text/dist" )[0 ]
412
409
embed_libgomp (host , use_conda , os .path .join ('text' , 'dist' , wheel_name ))
413
410
@@ -443,14 +440,14 @@ def build_torchaudio(host: RemoteHost, *,
443
440
build_vars = ""
444
441
if branch == 'nightly' :
445
442
version = host .check_output (["grep" , "\" version = '\" " , "audio/setup.py" ]).strip ().split ("'" )[1 ][:- 2 ]
446
- build_date = host .check_output ("cd pytorch ; git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" )
443
+ build_date = host .check_output ("cd audio && git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" )
447
444
build_vars += f"BUILD_VERSION={ version } .dev{ build_date } "
448
445
elif build_version is not None :
449
446
build_vars += f"BUILD_VERSION={ build_version } PYTORCH_VERSION={ branch [1 :].split ('-' )[0 ]} "
450
447
if host .using_docker ():
451
448
build_vars += " CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000"
452
449
453
- host .run_cmd (f"cd audio; { build_vars } python3 setup.py bdist_wheel" )
450
+ host .run_cmd (f"cd audio && { build_vars } python3 setup.py bdist_wheel" )
454
451
wheel_name = host .list_dir ("audio/dist" )[0 ]
455
452
embed_libgomp (host , use_conda , os .path .join ('audio' , 'dist' , wheel_name ))
456
453
@@ -523,7 +520,6 @@ def start_build(host: RemoteHost, *,
523
520
use_conda = use_conda ,
524
521
python_version = python_version )
525
522
build_OpenBLAS (host , git_clone_flags )
526
- # build_FFTW(host, git_clone_flags)
527
523
528
524
if host .using_docker ():
529
525
print ("Move libgfortant.a into a standard location" )
@@ -546,7 +542,7 @@ def start_build(host: RemoteHost, *,
546
542
# Breakpad build fails on aarch64
547
543
build_vars = "USE_BREAKPAD=0 "
548
544
if branch == 'nightly' :
549
- build_date = host .check_output ("cd pytorch ; git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" )
545
+ build_date = host .check_output ("cd pytorch && git log --pretty=format:%s -1" ).strip ().split ()[0 ].replace ("-" , "" )
550
546
version = host .check_output ("cat pytorch/version.txt" ).strip ()[:- 2 ]
551
547
build_vars += f"BUILD_TEST=0 PYTORCH_BUILD_VERSION={ version } .dev{ build_date } PYTORCH_BUILD_NUMBER=1"
552
548
if branch .startswith ("v1." ) or branch .startswith ("v2." ):
@@ -557,19 +553,19 @@ def start_build(host: RemoteHost, *,
557
553
build_ArmComputeLibrary (host , git_clone_flags )
558
554
print ("build pytorch with mkldnn+acl backend" )
559
555
build_vars += " USE_MKLDNN=ON USE_MKLDNN_ACL=ON"
560
- host .run_cmd (f"cd pytorch ; export ACL_ROOT_DIR=$HOME/ComputeLibrary:$HOME/acl; { build_vars } python3 setup.py bdist_wheel{ build_opts } " )
556
+ host .run_cmd (f"cd pytorch && export ACL_ROOT_DIR=$HOME/ComputeLibrary:$HOME/acl && { build_vars } python3 setup.py bdist_wheel{ build_opts } " )
561
557
print ('Repair the wheel' )
562
558
pytorch_wheel_name = host .list_dir ("pytorch/dist" )[0 ]
563
- host .run_cmd (f"export LD_LIBRARY_PATH=$HOME/acl/build:$HOME/pytorch/build/lib; auditwheel repair $HOME/pytorch/dist/{ pytorch_wheel_name } " )
559
+ host .run_cmd (f"export LD_LIBRARY_PATH=$HOME/acl/build:$HOME/pytorch/build/lib && auditwheel repair $HOME/pytorch/dist/{ pytorch_wheel_name } " )
564
560
print ('replace the original wheel with the repaired one' )
565
561
pytorch_repaired_wheel_name = host .list_dir ("wheelhouse" )[0 ]
566
562
host .run_cmd (f"cp $HOME/wheelhouse/{ pytorch_repaired_wheel_name } $HOME/pytorch/dist/{ pytorch_wheel_name } " )
567
563
else :
568
564
print ("build pytorch without mkldnn backend" )
569
- host .run_cmd (f"cd pytorch ; { build_vars } python3 setup.py bdist_wheel{ build_opts } " )
565
+ host .run_cmd (f"cd pytorch && { build_vars } python3 setup.py bdist_wheel{ build_opts } " )
570
566
571
567
print ("Deleting build folder" )
572
- host .run_cmd ("cd pytorch; rm -rf build" )
568
+ host .run_cmd ("cd pytorch && rm -rf build" )
573
569
pytorch_wheel_name = host .list_dir ("pytorch/dist" )[0 ]
574
570
embed_libgomp (host , use_conda , os .path .join ('pytorch' , 'dist' , pytorch_wheel_name ))
575
571
print ('Copying the wheel' )
0 commit comments