Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
coderai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
coderai
Commits
ad852d97
Commit
ad852d97
authored
Mar 15, 2026
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use CUDA only if --backend nvidia or --image-backend nvidia is specified
parent
27527de3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
20 deletions
+11
-20
coderai
coderai
+11
-20
No files found.
coderai
View file @
ad852d97
...
...
@@ -3665,34 +3665,25 @@ async def create_image_generation(request: ImageGenerationRequest):
sd_cpp_error = "Could not resolve model path"
else:
# Load sd.cpp model
# Determine backend to use
# Determine backend to use
based on CLI args
backend = getattr(global_args, '
backend
', '
auto
')
image_backend = getattr(global_args, '
image_backend
', '
auto
')
# Use CUDA if available, otherwise Vulkan
use_cuda = False
try:
import torch
use_cuda = torch.cuda.is_available()
except ImportError:
pass
# Use CUDA only if explicitly requested via --backend nvidia or --image-backend nvidia
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")
sd_model = StableDiffusion(
model_path=model_path,
vae_path=None,
n_threads=4,
n_gpu_layers=-1, # All layers to GPU
)
else:
print(f"Using Vulkan backend for sd.cpp image generation")
sd_model = StableDiffusion(
model_path=model_path,
vae_path=None,
n_threads=4,
n_gpu_layers=-1, # All layers to GPU
)
sd_model = StableDiffusion(
model_path=model_path,
vae_path=None,
n_threads=4,
n_gpu_layers=-1, # All layers to GPU
)
print(f"Using stable-diffusion-cpp-python for image generation")
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment