From 4cb8fd8c38717b99a4a3974968fc21284fd176d6 Mon Sep 17 00:00:00 2001 From: cslht Date: Thu, 6 Aug 2026 02:07:33 -0700 Subject: [PATCH] Fix check_training_ready crashing on CPU-only machines check_training_ready passed torch.device(torch.cuda.current_device()) as the default for the device attribute. Python evaluates keyword arguments at call time, so this unconditionally called torch.cuda.current_device(), which raises on systems without CUDA even though self.device is already set in __init__ and the default is never used. Use torch.cuda.is_available() instead, which is safe to call on CPU-only machines and preserves the GPU-default behavior. --- LION/optimizers/LIONsolver.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LION/optimizers/LIONsolver.py b/LION/optimizers/LIONsolver.py index 22fa8a54..5d6832f1 100644 --- a/LION/optimizers/LIONsolver.py +++ b/LION/optimizers/LIONsolver.py @@ -236,7 +236,9 @@ def check_training_ready(self, error=True, autofill=True, verbose=True): error=False, autofill=autofill, verbose=verbose, - default=torch.device(torch.cuda.current_device()), + default=torch.device( + torch.cuda.current_device() if torch.cuda.is_available() else "cpu" + ), ) # Test 2: is the model set? if not, raise error or warn