From ecd8d4e66dac3b684169006a84f845fbcef2e39d Mon Sep 17 00:00:00 2001 From: maybleMyers Date: Fri, 5 Dec 2025 03:55:20 -0800 Subject: [PATCH] add negative to positive --- modules/ui.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/ui.py b/modules/ui.py index 85f47384..8218eadc 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -347,10 +347,17 @@ def expand_prompt_standalone(prompt: str, model_path: str, system_prompt: str = log_step(" Loading model weights (this may take a moment)...") model_start = time.time() + + # Get the device the main program is using to avoid loading on wrong GPU + from backend import memory_management + main_device = memory_management.get_torch_device() + device_index = main_device.index if hasattr(main_device, 'index') and main_device.index is not None else 0 + log_step(f" Target device: cuda:{device_index}") + _expansion_model_cache['model'] = Qwen3VLForConditionalGeneration.from_pretrained( model_path, torch_dtype=torch.bfloat16, - device_map="auto", + device_map={"": f"cuda:{device_index}"}, ) _expansion_model_cache['model_path'] = model_path log_step(" Model weights loaded", model_start)