Skip to content

[Bug] Default device hardcoded to 'cuda' causes RuntimeError on CPU-only machines. #523

@NANDA2726

Description

@NANDA2726

The default device in app.py is hardcoded to "cuda":

st.session_state.setdefault("device", "cuda")

This causes a RuntimeError when users try to load a model on a CPU-only machine, even though the GUI explicitly supports cpu, cuda, and mps as device options in the sidebar dropdown.
The app is expected to dynamically detect the available device at runtime instead of assuming CUDA is always available.

Proposed Fix

if "device" not in st.session_state:
    if torch.cuda.is_available():
        default_device = "cuda"
    elif torch.backends.mps.is_available():
        default_device = "mps"
    else:
        default_device = "cpu"
        st.session_state.device = default_device

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions