-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to split model components to different backend devices #461
base: master
Are you sure you want to change the base?
Conversation
stable-diffusion.cpp
Outdated
} | ||
|
||
} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove whitespace
stable-diffusion.cpp
Outdated
if (model_backend_index == -1) { | ||
// default behavior, last device selected | ||
for (int device = 0; device < ggml_backend_vk_get_device_count(); ++device) { | ||
backend = ggml_backend_vk_init(device); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are initializing EVERY vk device here (and leak it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this from the original code verbatim in order to ensure that behavior prior to my changes was preserved. I just fixed it though. Instead of iterating over all device indexes, initializing all of them, and only keeping the last one, it instead simply picks the last index and initializes the corresponding backend device.
stable-diffusion.h
Outdated
bool keep_vae_on_cpu, | ||
int model_backend_index = -1, | ||
int clip_backend_index = -1, | ||
int vae_backend_index = -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C can not have default params
Removed whitespace, changed the default vulkan device initialization to use the last device without initializing all other previous devices.
Everything should be fixed now |
examples/cli/main.cpp
Outdated
@@ -5,6 +5,7 @@ | |||
#include <random> | |||
#include <string> | |||
#include <vector> | |||
#include <stdexcept> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no exceptions used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything else that needs changing?
The ability to specify separate backend device indexes for CLIP, Unet, and VAE was implemented. This works for all backends that accept a device index as an initialization parameter (CUDA, Vulkan, and SYCL.) The aim of this was to support splitting the parts of the model across multiple GPUs.