From cc4022d610ca9845248411d7b3c41deade5c753f Mon Sep 17 00:00:00 2001 From: runame Date: Thu, 19 Oct 2023 15:26:35 +0200 Subject: [PATCH] Skip tests on GPU when not available --- test/optim/test_kfac.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/optim/test_kfac.py b/test/optim/test_kfac.py index 8521515..73ec23e 100644 --- a/test/optim/test_kfac.py +++ b/test/optim/test_kfac.py @@ -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. @@ -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. @@ -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.