Commit 3367d957 authored by Your Name's avatar Your Name

Fix Vulkan crash when using --backend nvidia with preloaded image models

- Add VK_ICD_FILENAMES=/dev/null to disable Vulkan during startup preload
- Previously only set at request time, causing crash during --loadall
- Added check in both startup preload locations (lines ~5254 and ~5811)
- Checks --backend and --image-backend to determine CUDA usage
parent a4f36456
......@@ -5253,6 +5253,18 @@ def main():
try:
from stable_diffusion_cpp import StableDiffusion
# Disable Vulkan to force CUDA only for sd.cpp when using nvidia backend
image_backend = getattr(global_args, 'image_backend', 'auto')
backend = getattr(global_args, 'backend', 'auto')
use_cuda = (backend == 'nvidia' or backend == 'cuda' or
image_backend == 'nvidia' or image_backend == 'cuda')
if use_cuda:
print(f"Using CUDA backend for sd.cpp image generation")
# Disable Vulkan to force CUDA only
os.environ['VK_ICD_FILENAMES'] = '/dev/null'
else:
print(f"Using Vulkan backend for sd.cpp image generation")
# Initialize model_key to None first so Python knows it exists
model_key = None
......@@ -5799,6 +5811,18 @@ def main():
try:
from stable_diffusion_cpp import StableDiffusion
# Disable Vulkan to force CUDA only for sd.cpp when using nvidia backend
image_backend = getattr(global_args, 'image_backend', 'auto')
backend = getattr(global_args, 'backend', 'auto')
use_cuda = (backend == 'nvidia' or backend == 'cuda' or
image_backend == 'nvidia' or image_backend == 'cuda')
if use_cuda:
print(f"Using CUDA backend for sd.cpp image generation")
# Disable Vulkan to force CUDA only
os.environ['VK_ICD_FILENAMES'] = '/dev/null'
else:
print(f"Using Vulkan backend for sd.cpp image generation")
# Initialize model_key to avoid unbound variable error
model_key = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment