3
3
import os
4
4
import subprocess
5
5
from pygit2 import Repository
6
- from typing import Dict , List , Optional , Tuple
6
+ from typing import List
7
7
8
8
9
9
''''
@@ -13,26 +13,6 @@ def list_dir(path: str) -> List[str]:
13
13
return subprocess .check_output (["ls" , "-1" , path ]).decode ().split ("\n " )
14
14
15
15
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
-
36
16
'''
37
17
Using OpenBLAS with PyTorch
38
18
'''
@@ -60,186 +40,30 @@ def build_ArmComputeLibrary(git_clone_flags: str = "") -> None:
60
40
61
41
62
42
'''
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
72
44
'''
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 ]
151
47
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 ]
155
52
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/" )
199
60
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
203
62
204
63
205
64
'''
206
- Build TorchData wheel
65
+ Parse inline arguments
207
66
'''
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
-
243
67
def parse_arguments ():
244
68
from argparse import ArgumentParser
245
69
parser = ArgumentParser ("AARCH64 wheels python CD" )
@@ -286,37 +110,9 @@ def parse_arguments():
286
110
"LD_LIBRARY_PATH=/pytorch/build/lib:/acl/build " \
287
111
"ACL_INCLUDE_DIR=/acl/build " \
288
112
"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 } " )
298
113
else :
299
114
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 )
316
115
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 } .." )
0 commit comments