7
7
8
8
import argparse
9
9
import os
10
- import platform
11
- import re
12
10
import subprocess
13
11
import sys
14
12
15
-
16
- def python_is_compatible ():
17
- # Scrape the version range from pyproject.toml, which should be in the current directory.
18
- version_specifier = None
19
- with open ("pyproject.toml" , "r" ) as file :
20
- for line in file :
21
- if line .startswith ("requires-python" ):
22
- match = re .search (r'"([^"]*)"' , line )
23
- if match :
24
- version_specifier = match .group (1 )
25
- break
26
-
27
- if not version_specifier :
28
- print (
29
- "WARNING: Skipping python version check: version range not found" ,
30
- file = sys .stderr ,
31
- )
32
- return False
33
-
34
- # Install the packaging module if necessary.
35
- try :
36
- import packaging
37
- except ImportError :
38
- subprocess .run (
39
- [sys .executable , "-m" , "pip" , "install" , "packaging" ], check = True
40
- )
41
- # Compare the current python version to the range in version_specifier. Exits
42
- # with status 1 if the version is not compatible, or with status 0 if the
43
- # version is compatible or the logic itself fails.
44
- try :
45
- import packaging .specifiers
46
- import packaging .version
47
-
48
- python_version = packaging .version .parse (platform .python_version ())
49
- version_range = packaging .specifiers .SpecifierSet (version_specifier )
50
- if python_version not in version_range :
51
- print (
52
- f'ERROR: ExecuTorch does not support python version { python_version } : must satisfy "{ version_specifier } "' ,
53
- file = sys .stderr ,
54
- )
55
- return False
56
- except Exception as e :
57
- print (f"WARNING: Skipping python version check: { e } " , file = sys .stderr )
58
- return True
59
-
13
+ from install_utils import determine_torch_url , is_intel_mac_os , python_is_compatible
60
14
61
15
# The pip repository that hosts nightly torch packages.
62
- TORCH_NIGHTLY_URL = "https://download.pytorch.org/whl/nightly/cpu"
16
+ # This will be dynamically set based on CUDA availability and CUDA backend enabled/disabled.
17
+ TORCH_NIGHTLY_URL_BASE = "https://download.pytorch.org/whl/nightly"
63
18
19
+ # Supported CUDA versions - modify this to add/remove supported versions
20
+ # Format: tuple of (major, minor) version numbers
21
+ SUPPORTED_CUDA_VERSIONS = (
22
+ (12 , 6 ),
23
+ (12 , 8 ),
24
+ (12 , 9 ),
25
+ )
64
26
65
27
# Since ExecuTorch often uses main-branch features of pytorch, only the nightly
66
28
# pip versions will have the required features.
@@ -71,7 +33,10 @@ def python_is_compatible():
71
33
#
72
34
# NOTE: If you're changing, make the corresponding change in .ci/docker/ci_commit_pins/pytorch.txt
73
35
# by picking the hash from the same date in https://hud.pytorch.org/hud/pytorch/pytorch/nightly/
74
- NIGHTLY_VERSION = "dev20250906"
36
+ #
37
+ # NOTE: If you're changing, make the corresponding supported CUDA versions in
38
+ # SUPPORTED_CUDA_VERSIONS above if needed.
39
+ NIGHTLY_VERSION = "dev20250915"
75
40
76
41
77
42
def install_requirements (use_pytorch_nightly ):
@@ -84,12 +49,15 @@ def install_requirements(use_pytorch_nightly):
84
49
)
85
50
sys .exit (1 )
86
51
52
+ # Determine the appropriate PyTorch URL based on CUDA delegate status
53
+ torch_url = determine_torch_url (TORCH_NIGHTLY_URL_BASE , SUPPORTED_CUDA_VERSIONS )
54
+
87
55
# pip packages needed by exir.
88
56
TORCH_PACKAGE = [
89
57
# Setting use_pytorch_nightly to false to test the pinned PyTorch commit. Note
90
58
# that we don't need to set any version number there because they have already
91
59
# been installed on CI before this step, so pip won't reinstall them
92
- f"torch==2.9 .0.{ NIGHTLY_VERSION } " if use_pytorch_nightly else "torch" ,
60
+ f"torch==2.10 .0.{ NIGHTLY_VERSION } " if use_pytorch_nightly else "torch" ,
93
61
]
94
62
95
63
# Install the requirements for core ExecuTorch package.
@@ -105,7 +73,7 @@ def install_requirements(use_pytorch_nightly):
105
73
"requirements-dev.txt" ,
106
74
* TORCH_PACKAGE ,
107
75
"--extra-index-url" ,
108
- TORCH_NIGHTLY_URL ,
76
+ torch_url ,
109
77
],
110
78
check = True ,
111
79
)
@@ -147,10 +115,13 @@ def install_requirements(use_pytorch_nightly):
147
115
148
116
149
117
def install_optional_example_requirements (use_pytorch_nightly ):
118
+ # Determine the appropriate PyTorch URL based on CUDA delegate status
119
+ torch_url = determine_torch_url (TORCH_NIGHTLY_URL_BASE , SUPPORTED_CUDA_VERSIONS )
120
+
150
121
print ("Installing torch domain libraries" )
151
122
DOMAIN_LIBRARIES = [
152
123
(
153
- f"torchvision==0.24 .0.{ NIGHTLY_VERSION } "
124
+ f"torchvision==0.25 .0.{ NIGHTLY_VERSION } "
154
125
if use_pytorch_nightly
155
126
else "torchvision"
156
127
),
@@ -165,7 +136,7 @@ def install_optional_example_requirements(use_pytorch_nightly):
165
136
"install" ,
166
137
* DOMAIN_LIBRARIES ,
167
138
"--extra-index-url" ,
168
- TORCH_NIGHTLY_URL ,
139
+ torch_url ,
169
140
],
170
141
check = True ,
171
142
)
@@ -180,25 +151,14 @@ def install_optional_example_requirements(use_pytorch_nightly):
180
151
"-r" ,
181
152
"requirements-examples.txt" ,
182
153
"--extra-index-url" ,
183
- TORCH_NIGHTLY_URL ,
154
+ torch_url ,
184
155
"--upgrade-strategy" ,
185
156
"only-if-needed" ,
186
157
],
187
158
check = True ,
188
159
)
189
160
190
161
191
- # Prebuilt binaries for Intel-based macOS are no longer available on PyPI; users must compile from source.
192
- # PyTorch stopped building macOS x86_64 binaries since version 2.3.0 (January 2024).
193
- def is_intel_mac_os ():
194
- # Returns True if running on Intel macOS.
195
- return platform .system ().lower () == "darwin" and platform .machine ().lower () in (
196
- "x86" ,
197
- "x86_64" ,
198
- "i386" ,
199
- )
200
-
201
-
202
162
def main (args ):
203
163
parser = argparse .ArgumentParser ()
204
164
parser .add_argument (
0 commit comments