Skip to content

Notebook hardcodes cuda:1, contradicting README's CPU/single-GPU fallback #4

Description

@bushidocodes

Problem
The README states the notebook "defaults to cuda:1; it falls back to CPU" and says to edit "the relevant line in the second cell" for a single GPU. In reality cuda:1 is hardcoded in two places (the GCN.forward device move and the Trainer.__init__ device), and the selection is "cuda:1" if torch.cuda.is_available() and use_cuda .... On a machine with a single GPU (cuda:0 only), torch.cuda.is_available() is True, so the code selects the non-existent cuda:1 and raises a CUDA device error instead of falling back. The fix is also not in "the second cell" — it is in two later cells.

Evidence (My First Malware.ipynb)

  • Cell 11 (GCN.forward): g.ndata['h'] = feature.to(torch.device("cuda:1" if torch.cuda.is_available() and use_cuda is True else "cpu"))
  • Cell 17 (Trainer.__init__): self.device = torch.device("cuda:1" if torch.cuda.is_available() and use_cuda is True else "cpu")
  • README.md:121-129 claims a CPU fallback and points to "the second cell".

Impact
Anyone with a single-GPU box (the common case) cannot run the notebook as shipped — it errors out rather than degrading to cuda:0 or CPU, despite the README implying it works.

Recommendation
Define the device once near use_cuda (cell 1) as device = torch.device('cuda' if use_cuda and torch.cuda.is_available() else 'cpu') and reference that variable everywhere, or make the GPU index configurable. Align the README's "second cell" wording with the actual location.


Severity: low · Category: bug · Filed by an automated multi-repo code review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions