File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 135135 if problem_kind == "hopfield" :
136136 extra ["patterns" ] = st .slider ("Stored patterns P" , 1 , 20 , 3 )
137137
138- device = st .selectbox ("Device" , ("cpu" , "cuda" ), index = 0 )
138+ # Only offer devices that are actually available on the host. On public
139+ # deployments (Streamlit Cloud / Hugging Face Spaces) this is always
140+ # ``cpu``; on a local workstation with a GPU the ``cuda`` option appears.
141+ import torch # noqa: PLC0415 - lazy import to keep startup snappy
142+
143+ device_options = ["cpu" ]
144+ if torch .cuda .is_available ():
145+ device_options .append ("cuda" )
146+ device = st .selectbox (
147+ "Device" ,
148+ device_options ,
149+ index = 0 ,
150+ help = (
151+ "The annealing loop runs inside this Streamlit process. "
152+ "`cuda` appears only when a GPU is visible to PyTorch."
153+ ),
154+ )
139155
140156
141157# ---------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments