4
4
import torchvision
5
5
import torchaudio
6
6
7
- def smoke_test_cuda () -> None :
8
- gpu_arch_ver = os .getenv ('GPU_ARCH_VER' )
9
- gpu_arch_type = os .getenv ('GPU_ARCH_TYPE' )
10
- is_cuda_system = gpu_arch_type == "cuda"
7
+ gpu_arch_ver = os .getenv ('GPU_ARCH_VER' )
8
+ gpu_arch_type = os .getenv ('GPU_ARCH_TYPE' )
9
+ is_cuda_system = gpu_arch_type == "cuda"
11
10
11
+ def smoke_test_cuda () -> None :
12
12
if (not torch .cuda .is_available () and is_cuda_system ):
13
13
print (f"Expected CUDA { gpu_arch_ver } . However CUDA is not loaded." )
14
14
sys .exit (1 )
@@ -21,6 +21,25 @@ def smoke_test_cuda() -> None:
21
21
#todo add cudnn version validation
22
22
print (f"torch cudnn: { torch .backends .cudnn .version ()} " )
23
23
24
+ def smoke_test_conv2d () -> None :
25
+ import torch .nn as nn
26
+ print (f"Calling smoke_test_conv2d" )
27
+ # With square kernels and equal stride
28
+ m = nn .Conv2d (16 , 33 , 3 , stride = 2 )
29
+ # non-square kernels and unequal stride and with padding
30
+ m = nn .Conv2d (16 , 33 , (3 , 5 ), stride = (2 , 1 ), padding = (4 , 2 ))
31
+ # non-square kernels and unequal stride and with padding and dilation
32
+ m = nn .Conv2d (16 , 33 , (3 , 5 ), stride = (2 , 1 ), padding = (4 , 2 ), dilation = (3 , 1 ))
33
+ input = torch .randn (20 , 16 , 50 , 100 )
34
+ output = m (input )
35
+ if (is_cuda_system ):
36
+ print (f"Testing smoke_test_conv2d with cuda" )
37
+ conv = nn .Conv2d (3 , 3 , 3 ).cuda ()
38
+ x = torch .randn (1 , 3 , 24 , 24 ).cuda ()
39
+ with torch .cuda .amp .autocast ():
40
+ out = conv (x )
41
+ print (out .sum ())
42
+
24
43
def smoke_test_torchvision () -> None :
25
44
import torchvision .datasets as dset
26
45
import torchvision .transforms
@@ -53,7 +72,7 @@ def smoke_test_vision_resnet50_classify() -> None:
53
72
class_id = prediction .argmax ().item ()
54
73
score = prediction [class_id ].item ()
55
74
category_name = weights .meta ["categories" ][class_id ]
56
- expected_category = "German sheppard "
75
+ expected_category = "German shepherd "
57
76
print (f"{ category_name } : { 100 * score :.1f} %" )
58
77
if (category_name != expected_category ):
59
78
print (f"Failed ResNet50 classify { category_name } Expected: { expected_category } " )
@@ -77,6 +96,7 @@ def main() -> None:
77
96
print (f"torchvision: { torchvision .__version__ } " )
78
97
print (f"torchaudio: { torchaudio .__version__ } " )
79
98
smoke_test_cuda ()
99
+ smoke_test_conv2d ()
80
100
smoke_test_torchvision ()
81
101
smoke_test_torchaudio ()
82
102
smoke_test_vision_resnet50_classify ()
0 commit comments