Skip to content

Commit

Permalink
Skip tests on GPU when not available
Browse files Browse the repository at this point in the history
  • Loading branch information
runame committed Oct 19, 2023
1 parent 96a8e82 commit cc4022d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/optim/test_kfac.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def test_kfac_single_linear_module(
Raises:
AssertionError: If the KFAC approximation is not exact.
"""
if not torch.cuda.is_available() and device.type == "cuda":
return
# Fix random seed.
torch.manual_seed(711)
# Set up inputs x.
Expand Down Expand Up @@ -101,6 +103,8 @@ def test_kfac_deep_linear(
AssertionError: If the KFAC approximation is not exact for the block
diagonal.
"""
if not torch.cuda.is_available() and device.type == "cuda":
return
# Fix random seed.
torch.manual_seed(711)
# Set up inputs x.
Expand Down Expand Up @@ -166,6 +170,8 @@ def test_kfac_conv2d_module(
AssertionError: If the KFAC-reduce approximation is not exact for the
diagonal or the Conv2d layer or if it is exact for KFAC-expand.
"""
if not torch.cuda.is_available() and device.type == "cuda":
return
# Fix random seed.
torch.manual_seed(711)
# Set up inputs x.
Expand Down

0 comments on commit cc4022d

Please sign in to comment.