Skip to content

Commit bbf0ab0

Browse files
joao-alex-cunharwightman
authored andcommitted
return if cuda not available
1 parent e628ed7 commit bbf0ab0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tests/test_optim.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ def fn_base(optimizer, weight, bias):
106106
# to a different type and move to a different device.
107107
if torch_device == 'cpu':
108108
return
109+
elif torch_device == 'cuda' and not torch.cuda.is_available:
110+
return
109111

110112
with torch.no_grad():
111113
input_device = Parameter(input.clone().detach().float().to(torch_device))
@@ -161,6 +163,9 @@ def _test_basic_cases(constructor, scheduler_constructors=None):
161163
# CUDA
162164
if torch_device == 'cpu':
163165
return
166+
elif torch_device == 'cuda' and not torch.cuda.is_available():
167+
return
168+
164169
_test_basic_cases_template(
165170
torch.randn(10, 5).to(torch_device),
166171
torch.randn(10).to(torch_device),

0 commit comments

Comments
 (0)