mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-28 19:16:33 +00:00
--profile max|balanced|lite|auto sets, in one option, what a small machine needs: balanced turns the memory guard on at 90; lite also puts the text encoder on the CPU, tiles the VAE, runs CFG unbatched and lowers the guard to 85. An option given on the command line always wins over the profile, including --memory-guard 0. A profile does not touch --params-backend or --backend, so --auto-fit keeps deciding where the weights live, and it never changes the size or the steps of an image. auto compares the size of the model files plus a working-memory reserve with the free memory of the discrete GPU with the most, or with the available RAM without one, and logs the figures it used. It leaves the defaults alone when the sizes or the memory are unknown. parse_options() now records which options were given, through option_was_given(). The levels below lite (weights streamed from disk, everything on the CPU) cannot be chosen from the command line; they are the steps a server takes when a request runs out of memory. The thresholds of auto are heuristics and have not been tuned on a real model or a GPU. Checked with the synthetic SD 1.5 model on the CPU: the three profiles give the same image, and with 3.3 GiB held by another process auto picks balanced. Claude-Session: https://claude.ai/code/session_01EhZzDBkuuMp1jBf4WtEySC
28 lines
812 B
CMake
28 lines
812 B
CMake
set(TARGET sd-cli)
|
|
|
|
add_executable(${TARGET}
|
|
../common/common.cpp
|
|
../common/log.cpp
|
|
../common/media_io.cpp
|
|
../common/profile.cpp
|
|
image_metadata.cpp
|
|
main.cpp
|
|
)
|
|
if(APPLE)
|
|
sd_set_macos_rpaths(${TARGET})
|
|
endif()
|
|
target_include_directories(${TARGET} PRIVATE
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/.."
|
|
"${PROJECT_SOURCE_DIR}/src"
|
|
)
|
|
install(TARGETS ${TARGET} RUNTIME)
|
|
target_link_libraries(${TARGET} PRIVATE stable-diffusion zip ${CMAKE_THREAD_LIBS_INIT})
|
|
if(SD_WEBP)
|
|
target_compile_definitions(${TARGET} PRIVATE SD_USE_WEBP)
|
|
target_link_libraries(${TARGET} PRIVATE webp libwebpmux)
|
|
endif()
|
|
if(SD_WEBM)
|
|
target_compile_definitions(${TARGET} PRIVATE SD_USE_WEBM)
|
|
target_link_libraries(${TARGET} PRIVATE webm)
|
|
endif()
|
|
target_compile_features(${TARGET} PUBLIC c_std_11 cxx_std_17)
|