Skip to content

[Bug]: Using GGUF_THREADS environment variable causes a crash #368

@coolguy45

Description

@coolguy45

fastsdcpu Version

v1.0.0 beta 281

Bug Description

When the environment variable GGUF_THREADS is set, the application crashes during GGUF model initialization. This is due to a type mismatch where the environment variable is passed as a string to the new_sd_ctx function in the C++ backend, which expects an integer.

Suggested Fix
Explicitly cast the environment variable to an integer in src/constants.py:

Current code (src/constants.py):
GGUF_THREADS = environ.get("GGUF_THREADS", cpus)

Suggested Fix:
GGUF_THREADS = int(environ.get("GGUF_THREADS", cpus))

Steps to Reproduce

  1. Export the environment variable: export GGUF_THREADS=4 (or any value).
  2. Run fastsdcpu.
  3. Attempt to generate an image using a GGUF model (e.g., Flux).
  4. See ctypes.ArgumentError: argument 14: TypeError: wrong type.

Expected Behavior

Expected the program to use the variable and execute.

Logs / Error Output

File "/src/backend/gguf/gguf_diffusion.py", line 146, in __init__
    self.sd_ctx = self.libsdcpp.new_sd_ctx(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
ctypes.ArgumentError: argument 14: TypeError: wrong type

Operating System

Linux

Hardware / CPU

No response

Checklist

  • I searched existing issues
  • I am using a supported environment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions