Skip to content

fall back to CPU if no GPUs are available#8

Merged
TahaBinhuraib merged 1 commit intomainfrom
device-fix
Oct 24, 2025
Merged

fall back to CPU if no GPUs are available#8
TahaBinhuraib merged 1 commit intomainfrom
device-fix

Conversation

@Mayukhdeb
Copy link
Collaborator

Fixes the UnboundLocalError that occurs when use_gpu is True but there's no GPUs available on the machine.

Traceback:

Traceback (most recent call last):
  File "/home/cierra/repos/litcoder_core/train_simple.py", line 49, in <module>
    metrics = trainer.train()
              ^^^^^^^^^^^^^^^
  File "/home/cierra/repos/litcoder_core/encoding/trainer.py", line 299, in train
    metrics, weights, best_alphas = self.model.fit_predict(
                                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cierra/repos/litcoder_core/encoding/models/nested_cv.py", line 96, in fit_predict
    features_torch = torch.tensor(features, dtype=torch.float32, device=device)
                                                                        ^^^^^^
UnboundLocalError: cannot access local variable 'device' where it is not associated with a value
wandb:
wandb: 🚀 View run abstract-trainer-20251023-135951 at:
wandb: Find logs at: wandb/run-20251023_135951-u7d8ziyj/logs
(litcoder) cierra@xiyarui:~/repos/litcoder_core$ 

@TahaBinhuraib TahaBinhuraib merged commit 246a048 into main Oct 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants