5
5
import argparse
6
6
import torch
7
7
8
-
9
-
10
8
gpu_arch_ver = os .getenv ("GPU_ARCH_VER" )
11
9
gpu_arch_type = os .getenv ("GPU_ARCH_TYPE" )
12
10
# use installation env variable to tell if it is nightly channel
13
11
installation_str = os .getenv ("INSTALLATION" )
14
12
is_cuda_system = gpu_arch_type == "cuda"
15
13
SCRIPT_DIR = Path (__file__ ).parent
14
+ NIGHTLY_ALLOWED_DELTA = 3
16
15
17
16
# helper function to return the conda installed packages
18
17
# and return package we are insterseted in
@@ -35,32 +34,31 @@ def get_anaconda_output_for_package(pkg_name_str):
35
34
36
35
37
36
def check_nightly_binaries_date (package : str ) -> None :
37
+ from datetime import datetime , timedelta
38
+ format_dt = '%Y%m%d'
39
+
38
40
torch_str = torch .__version__
39
41
date_t_str = re .findall ("dev\d+" , torch .__version__ )
42
+ date_t_delta = datetime .now () - datetime .strptime (date_t_str .lstrip ("dev" ), format_dt )
43
+ if date_t_delta .days >= NIGHTLY_ALLOWED_DELTA :
44
+ raise RuntimeError (
45
+ f"the binaries are from { date_t_str } and are more than { NIGHTLY_ALLOWED_DELTA } days old!"
46
+ )
40
47
41
48
if (package == "all" ):
42
49
ta_str = torchaudio .__version__
43
50
tv_str = torchvision .__version__
44
51
date_ta_str = re .findall ("dev\d+" , torchaudio .__version__ )
45
52
date_tv_str = re .findall ("dev\d+" , torchvision .__version__ )
53
+ date_ta_delta = datetime .now () - datetime .strptime (date_ta_str .lstrip ("dev" ), format_dt )
54
+ date_tv_delta = datetime .now () - datetime .strptime (date_tv_str .lstrip ("dev" ), format_dt )
46
55
47
56
# check that the above three lists are equal and none of them is empty
48
- if not date_t_str or not date_t_str == date_ta_str == date_tv_str :
57
+ if date_ta_delta . days > NIGHTLY_ALLOWED_DELTA or date_tv_delta . days > NIGHTLY_ALLOWED_DELTA :
49
58
raise RuntimeError (
50
- f"Expected torch, torchaudio, torchvision to be the same date . But they are from { date_t_str } , { date_ta_str } , { date_tv_str } respectively"
59
+ f"Expected torchaudio, torchvision to be less then { NIGHTLY_ALLOWED_DELTA } days . But they are from { date_ta_str } , { date_tv_str } respectively"
51
60
)
52
61
53
- # check that the date is recent, at this point, date_torch_str is not empty
54
- binary_date_str = date_t_str [0 ][3 :]
55
- from datetime import datetime
56
-
57
- binary_date_obj = datetime .strptime (binary_date_str , "%Y%m%d" ).date ()
58
- today_obj = datetime .today ().date ()
59
- delta = today_obj - binary_date_obj
60
- if delta .days >= 2 :
61
- raise RuntimeError (
62
- f"the binaries are from { binary_date_obj } and are more than 2 days old!"
63
- )
64
62
65
63
def smoke_test_cuda (package : str ) -> None :
66
64
if not torch .cuda .is_available () and is_cuda_system :
@@ -76,6 +74,8 @@ def smoke_test_cuda(package: str) -> None:
76
74
print (f"cuDNN enabled? { torch .backends .cudnn .enabled } " )
77
75
78
76
if (package == 'all' ):
77
+ import torchaudio
78
+ import torchvision
79
79
if installation_str .find ("nightly" ) != - 1 :
80
80
# just print out cuda version, as version check were already performed during import
81
81
print (f"torchvision cuda: { torch .ops .torchvision ._cuda_version ()} " )
@@ -165,6 +165,7 @@ def smoke_test_torchvision_resnet50_classify(device: str = "cpu") -> None:
165
165
166
166
167
167
def smoke_test_torchaudio () -> None :
168
+ import torchaudio
168
169
import torchaudio .compliance .kaldi # noqa: F401
169
170
import torchaudio .datasets # noqa: F401
170
171
import torchaudio .functional # noqa: F401
@@ -184,20 +185,18 @@ def main() -> None:
184
185
choices = ["all" , "torchonly" ],
185
186
default = "all" ,
186
187
)
187
-
188
+ options = parser . parse_args ()
188
189
print (f"torch: { torch .__version__ } " )
190
+
189
191
smoke_test_cuda (options .package )
190
192
smoke_test_conv2d ()
191
193
192
194
# only makes sense to check nightly package where dates are known
193
195
if installation_str .find ("nightly" ) != - 1 :
194
- check_nightly_binaries_date ()
196
+ check_nightly_binaries_date (options . package )
195
197
196
198
if options .package == "all" :
197
199
import torchaudio
198
- # the following import would invoke
199
- # _check_cuda_version()
200
- # via torchvision.extension._check_cuda_version()
201
200
import torchvision
202
201
print (f"torchvision: { torchvision .__version__ } " )
203
202
print (f"torchaudio: { torchaudio .__version__ } " )
0 commit comments