fix: use torch device class instead of string for compatibility with comfy memory management #200
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
comfy.model_management.free_memory
function expects thedevice
param to be a<class 'torch.device'>
. Currently this equality check fails because it's comparing a<class 'torch.device'>
with astr
.This proposed change fixes one class of OOM on my laptop's 8GB RTX 2070 GPU.
I think there is at least one other change needed to play nice with Comfy's memory management on low-VRAM GPUs. I think the main one is related to:
because the model.detach call here doesn't seem to work. If I can work that out I'll propose that change in separate pull request.