Skip to content

Commit 6240da5

Browse files
author
Mike Schneider
authored
Update CI for aarch64 (#1438)
1 parent 9d42578 commit 6240da5

File tree

3 files changed

+35
-232
lines changed

3 files changed

+35
-232
lines changed

aarch64_linux/aarch64_ci_build.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PATH=/opt/conda/bin:$PATH
1212
# Install OS dependent packages
1313
###############################################################################
1414
yum -y install epel-release
15-
yum -y install less zstd git
15+
yum -y install less zstd libgomp
1616

1717
###############################################################################
1818
# Install conda
@@ -38,17 +38,17 @@ conda --version
3838
###############################################################################
3939
cd ~/
4040
curl -L -o ~/libgfortran-10-dev.deb http://ports.ubuntu.com/ubuntu-ports/pool/universe/g/gcc-10/libgfortran-10-dev_10.4.0-8ubuntu1_arm64.deb
41-
ar -x libgfortran-10-dev.deb
41+
ar x ~/libgfortran-10-dev.deb
4242
tar --use-compress-program=unzstd -xvf data.tar.zst -C ~/
4343
cp -f ~/usr/lib/gcc/aarch64-linux-gnu/10/libgfortran.a /opt/rh/devtoolset-10/root/usr/lib/gcc/aarch64-redhat-linux/10/
4444

4545
###############################################################################
4646
# Run aarch64 builder python
4747
###############################################################################
48-
cd /pytorch
48+
cd /
4949
# adding safe directory for git as the permissions will be
5050
# on the mounted pytorch repo
5151
git config --global --add safe.directory /pytorch
5252
pip install -r /pytorch/requirements.txt
5353
pip install auditwheel
54-
python /builder/aarch64_linux/aarch64_wheel_ci_build.py --enable-mkldnn
54+
python /builder/aarch64_linux/aarch64_wheel_ci_build.py --enable-mkldnn

aarch64_linux/aarch64_wheel_ci_build.py

Lines changed: 20 additions & 224 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import subprocess
55
from pygit2 import Repository
6-
from typing import Dict, List, Optional, Tuple
6+
from typing import List
77

88

99
''''
@@ -13,26 +13,6 @@ def list_dir(path: str) -> List[str]:
1313
return subprocess.check_output(["ls", "-1", path]).decode().split("\n")
1414

1515

16-
'''
17-
Helper to get repo branches for specific versions
18-
'''
19-
def checkout_repo(
20-
package: str,
21-
branch: str = "main",
22-
url: str = "",
23-
git_clone_flags: str = "",
24-
mapping: Dict[str, Tuple[str, str]] = []) -> Optional[str]:
25-
for prefix in mapping:
26-
if not branch.startswith(prefix):
27-
continue
28-
tag = f"v{mapping[prefix][0]}-{mapping[prefix][1]}"
29-
os.system(f"git clone {url} /{package} -b {tag} {git_clone_flags}")
30-
return mapping[prefix][0]
31-
32-
os.system(f"git clone {url} /{package} {git_clone_flags}")
33-
return None
34-
35-
3616
'''
3717
Using OpenBLAS with PyTorch
3818
'''
@@ -60,186 +40,30 @@ def build_ArmComputeLibrary(git_clone_flags: str = "") -> None:
6040

6141

6242
'''
63-
Script to embed libgomp to the wheels
64-
'''
65-
def embed_libgomp(wheel_name) -> None:
66-
print('Embedding libgomp into wheel')
67-
os.system(f"python3 /builder/aarch64_linux/embed_library.py {wheel_name} --update-tag")
68-
69-
70-
'''
71-
Build TorchVision wheel
43+
Complete wheel build and put in artifact location
7244
'''
73-
def build_torchvision(branch: str = "main",
74-
git_clone_flags: str = "") -> str:
75-
print('Checking out TorchVision repo')
76-
build_version = checkout_repo(package="vision",
77-
branch=branch,
78-
url="https://github.com/pytorch/vision",
79-
git_clone_flags=git_clone_flags,
80-
mapping={
81-
"v1.7.1": ("0.8.2", "rc2"),
82-
"v1.8.0": ("0.9.0", "rc3"),
83-
"v1.8.1": ("0.9.1", "rc1"),
84-
"v1.9.0": ("0.10.0", "rc1"),
85-
"v1.10.0": ("0.11.1", "rc1"),
86-
"v1.10.1": ("0.11.2", "rc1"),
87-
"v1.10.2": ("0.11.3", "rc1"),
88-
"v1.11.0": ("0.12.0", "rc1"),
89-
"v1.12.0": ("0.13.0", "rc4"),
90-
"v1.12.1": ("0.13.1", "rc6"),
91-
"v1.13.0": ("0.14.0", "rc4"),
92-
"v1.13.1": ("0.14.1", "rc2"),
93-
"v2.0.0": ("0.15.0", "rc2"),
94-
})
95-
print('Building TorchVision wheel')
96-
build_vars = "CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000 "
97-
if branch == 'nightly':
98-
version = ''
99-
if os.path.exists('/vision/version.txt'):
100-
version = subprocess.check_output(['cat', '/vision/version.txt']).decode().strip()
101-
if len(version) == 0:
102-
# In older revisions, version was embedded in setup.py
103-
version = subprocess.check_output(['grep', 'version', 'setup.py']).decode().strip().split('\'')[1][:-2]
104-
build_date = subprocess.check_output(['git','log','--pretty=format:%cs','-1'], cwd='/vision').decode().replace('-','')
105-
build_vars += f"BUILD_VERSION={version}.dev{build_date}"
106-
elif build_version is not None:
107-
build_vars += f"BUILD_VERSION={build_version}"
108-
109-
os.system(f"cd /vision; {build_vars} python3 setup.py bdist_wheel")
110-
wheel_name = list_dir("/vision/dist")[0]
111-
embed_libgomp(f"/vision/dist/{wheel_name}")
112-
113-
print('Move TorchVision wheel to artfacts')
114-
os.system(f"mv /vision/dist/{wheel_name} /artifacts/")
115-
return wheel_name
116-
117-
118-
'''
119-
Build TorchAudio wheel
120-
'''
121-
def build_torchaudio(branch: str = "main",
122-
git_clone_flags: str = "") -> str:
123-
print('Checking out TorchAudio repo')
124-
git_clone_flags += " --recurse-submodules"
125-
build_version = checkout_repo(package="audio",
126-
branch=branch,
127-
url="https://github.com/pytorch/audio",
128-
git_clone_flags=git_clone_flags,
129-
mapping={
130-
"v1.9.0": ("0.9.0", "rc2"),
131-
"v1.10.0": ("0.10.0", "rc5"),
132-
"v1.10.1": ("0.10.1", "rc1"),
133-
"v1.10.2": ("0.10.2", "rc1"),
134-
"v1.11.0": ("0.11.0", "rc1"),
135-
"v1.12.0": ("0.12.0", "rc3"),
136-
"v1.12.1": ("0.12.1", "rc5"),
137-
"v1.13.0": ("0.13.0", "rc4"),
138-
"v1.13.1": ("0.13.1", "rc2"),
139-
"v2.0.0": ("2.0.0", "rc2"),
140-
})
141-
print('Building TorchAudio wheel')
142-
build_vars = "CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000 "
143-
if branch == 'nightly':
144-
version = ''
145-
if os.path.exists('/audio/version.txt'):
146-
version = subprocess.check_output(['cat', '/audio/version.txt']).decode().strip()
147-
build_date = subprocess.check_output(['git','log','--pretty=format:%cs','-1'], cwd='/audio').decode().replace('-','')
148-
build_vars += f"BUILD_VERSION={version}.dev{build_date}"
149-
elif build_version is not None:
150-
build_vars += f"BUILD_VERSION={build_version}"
45+
def complete_wheel(folder: str):
46+
wheel_name = list_dir(f"/{folder}/dist")[0]
15147

152-
os.system(f"cd /audio; {build_vars} python3 setup.py bdist_wheel")
153-
wheel_name = list_dir("/audio/dist")[0]
154-
embed_libgomp(f"/audio/dist/{wheel_name}")
48+
if "pytorch" in folder:
49+
print("Repairing Wheel with AuditWheel")
50+
os.system(f"cd /{folder}; auditwheel repair dist/{wheel_name}")
51+
repaired_wheel_name = list_dir(f"/{folder}/wheelhouse")[0]
15552

156-
print('Move TorchAudio wheel to artfacts')
157-
os.system(f"mv /audio/dist/{wheel_name} /artifacts/")
158-
return wheel_name
159-
160-
161-
'''
162-
Build TorchText wheel
163-
'''
164-
def build_torchtext(branch: str = "main",
165-
git_clone_flags: str = "") -> str:
166-
print('Checking out TorchText repo')
167-
os.system(f"cd /")
168-
git_clone_flags += " --recurse-submodules"
169-
build_version = checkout_repo(package="text",
170-
branch=branch,
171-
url="https://github.com/pytorch/text",
172-
git_clone_flags=git_clone_flags,
173-
mapping={
174-
"v1.9.0": ("0.10.0", "rc1"),
175-
"v1.10.0": ("0.11.0", "rc2"),
176-
"v1.10.1": ("0.11.1", "rc1"),
177-
"v1.10.2": ("0.11.2", "rc1"),
178-
"v1.11.0": ("0.12.0", "rc1"),
179-
"v1.12.0": ("0.13.0", "rc2"),
180-
"v1.12.1": ("0.13.1", "rc5"),
181-
"v1.13.0": ("0.14.0", "rc3"),
182-
"v1.13.1": ("0.14.1", "rc1"),
183-
"v2.0.0": ("0.15.0", "rc2"),
184-
})
185-
print('Building TorchText wheel')
186-
build_vars = "CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000 "
187-
if branch == 'nightly':
188-
version = ''
189-
if os.path.exists('/text/version.txt'):
190-
version = subprocess.check_output(['cat', '/text/version.txt']).decode().strip()
191-
build_date = subprocess.check_output(['git','log','--pretty=format:%cs','-1'], cwd='/text').decode().replace('-','')
192-
build_vars += f"BUILD_VERSION={version}.dev{build_date}"
193-
elif build_version is not None:
194-
build_vars += f"BUILD_VERSION={build_version}"
195-
196-
os.system(f"cd /text; {build_vars} python3 setup.py bdist_wheel")
197-
wheel_name = list_dir("/text/dist")[0]
198-
embed_libgomp(f"/text/dist/{wheel_name}")
53+
print(f"Moving {repaired_wheel_name} wheel to /{folder}/dist")
54+
os.system(f"mv /{folder}/wheelhouse/{repaired_wheel_name} /{folder}/dist/")
55+
else:
56+
repaired_wheel_name = wheel_name
57+
58+
print(f"Copying {repaired_wheel_name} to artfacts")
59+
os.system(f"mv /{folder}/dist/{repaired_wheel_name} /artifacts/")
19960

200-
print('Move TorchText wheel to artfacts')
201-
os.system(f"mv /text/dist/{wheel_name} /artifacts/")
202-
return wheel_name
61+
return repaired_wheel_name
20362

20463

20564
'''
206-
Build TorchData wheel
65+
Parse inline arguments
20766
'''
208-
def build_torchdata(branch: str = "main",
209-
git_clone_flags: str = "") -> str:
210-
print('Checking out TorchData repo')
211-
git_clone_flags += " --recurse-submodules"
212-
build_version = checkout_repo(package="data",
213-
branch=branch,
214-
url="https://github.com/pytorch/data",
215-
git_clone_flags=git_clone_flags,
216-
mapping={
217-
"v1.11.0": ("0.3.0", "rc1"),
218-
"v1.12.0": ("0.4.0", "rc3"),
219-
"v1.12.1": ("0.4.1", "rc5"),
220-
"v1.13.1": ("0.5.1", "rc2"),
221-
"v2.0.0": ("0.6.0", "rc2"),
222-
})
223-
print('Building TorchData wheel')
224-
build_vars = "CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000 "
225-
if branch == 'nightly':
226-
version = ''
227-
if os.path.exists('/data/version.txt'):
228-
version = subprocess.check_output(['cat', '/data/version.txt']).decode().strip()
229-
build_date = subprocess.check_output(['git','log','--pretty=format:%cs','-1'], cwd='/data').decode().replace('-','')
230-
build_vars += f"BUILD_VERSION={version}.dev{build_date}"
231-
elif build_version is not None:
232-
build_vars += f"BUILD_VERSION={build_version}"
233-
234-
os.system(f"cd /data; {build_vars} python3 setup.py bdist_wheel")
235-
wheel_name = list_dir("/data/dist")[0]
236-
embed_libgomp(f"/data/dist/{wheel_name}")
237-
238-
print('Move TorchAudio wheel to artfacts')
239-
os.system(f"mv /data/dist/{wheel_name} /artifacts/")
240-
return wheel_name
241-
242-
24367
def parse_arguments():
24468
from argparse import ArgumentParser
24569
parser = ArgumentParser("AARCH64 wheels python CD")
@@ -286,37 +110,9 @@ def parse_arguments():
286110
"LD_LIBRARY_PATH=/pytorch/build/lib:/acl/build " \
287111
"ACL_INCLUDE_DIR=/acl/build " \
288112
"ACL_LIBRARY=/acl/build "
289-
os.system(f"cd /pytorch; {build_vars} python3 setup.py bdist_wheel")
290-
291-
## Using AuditWheel on the pip package.
292-
print('Repair the wheel')
293-
pytorch_wheel_name = list_dir("/pytorch/dist")[0]
294-
os.system(f"LD_LIBRARY_PATH=/pytorch/build/lib:/acl/build auditwheel repair /pytorch/dist/{pytorch_wheel_name}")
295-
print('replace the original wheel with the repaired one')
296-
pytorch_repaired_wheel_name = list_dir("wheelhouse")[0]
297-
os.system(f"cp /wheelhouse/{pytorch_repaired_wheel_name} /pytorch/dist/{pytorch_wheel_name}")
298113
else:
299114
print("build pytorch without mkldnn backend")
300-
build_vars += "LD_LIBRARY_PATH=/pytorch/build/lib "
301-
os.system(f"cd /pytorch; {build_vars} python3 setup.py bdist_wheel")
302-
303-
print("Deleting build folder")
304-
os.system("cd /pytorch; rm -rf build")
305-
pytorch_wheel_name = list_dir("/pytorch/dist")[0]
306-
embed_libgomp(f"/pytorch/dist/{pytorch_wheel_name}")
307-
print('Move PyTorch wheel to artfacts')
308-
os.system(f"mv /pytorch/dist/{pytorch_wheel_name} /artifacts/")
309-
print("Installing Pytorch wheel")
310-
os.system(f"pip install /artifacts/{pytorch_wheel_name}")
311-
312-
vision_wheel_name = build_torchvision(branch=branch, git_clone_flags=git_clone_flags)
313-
audio_wheel_name = build_torchaudio(branch=branch, git_clone_flags=git_clone_flags)
314-
text_wheel_name = build_torchtext(branch=branch, git_clone_flags=git_clone_flags)
315-
data_wheel_name = build_torchdata(branch=branch, git_clone_flags=git_clone_flags)
316115

317-
print(f"Wheels Created:\n" \
318-
f"{pytorch_wheel_name}\n" \
319-
f"{vision_wheel_name}\n" \
320-
f"{audio_wheel_name}\n" \
321-
f"{text_wheel_name}\n" \
322-
f"{data_wheel_name}\n")
116+
os.system(f"cd /pytorch; {build_vars} python3 setup.py bdist_wheel")
117+
pytorch_wheel_name = complete_wheel("pytorch")
118+
print(f"Build Compelete. Created {pytorch_wheel_name}..")

check_binary.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,17 @@ if [[ "$PACKAGE_TYPE" == 'libtorch' ]]; then
343343
build_and_run_example_cpp check-torch-mkl
344344
elif [[ "$(uname -m)" != "arm64" ]]; then
345345
if [[ "$(uname)" != 'Darwin' || "$PACKAGE_TYPE" != *wheel ]]; then
346-
echo "Checking that MKL is available"
347-
pushd /tmp
348-
python -c 'import torch; exit(0 if torch.backends.mkl.is_available() else 1)'
349-
popd
346+
if [[ "$(uname -m)" == "aarch64" ]]; then
347+
echo "Checking that MKLDNN is available on aarch64"
348+
pushd /tmp
349+
python -c 'import torch; exit(0 if torch.backends.mkldnn.is_available() else 1)'
350+
popd
351+
else
352+
echo "Checking that MKL is available"
353+
pushd /tmp
354+
python -c 'import torch; exit(0 if torch.backends.mkl.is_available() else 1)'
355+
popd
356+
fi
350357
fi
351358
fi
352359

0 commit comments

Comments
 (0)