Skip to content

Commit

Permalink
image: Use deepcache to optimise sd model
Browse files Browse the repository at this point in the history
Which bring 2x speed-up
  • Loading branch information
frostyplanet committed Sep 27, 2024
1 parent 3369106 commit 7ff4245
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ rerank =
image =
diffusers>=0.30.0 # fix conflict with matcha-tts
controlnet_aux
deepcache
video =
diffusers>=0.30.0
imageio-ffmpeg
Expand Down
1 change: 1 addition & 0 deletions xinference/deploy/docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ ormsgpack # For Fish Speech
qwen-vl-utils # For qwen2-vl
datamodel_code_generator # for minicpm-4B
jsonschema # for minicpm-4B
deepcache # for sd

# sglang
outlines>=0.0.44
Expand Down
8 changes: 8 additions & 0 deletions xinference/model/image/stable_diffusion/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ def load(self):
elif not self._kwargs.get("device_map"):
logger.debug("Loading model to available device")
self._model = move_model_to_available_device(self._model)
try:
from DeepCache import DeepCacheSDHelper

helper = DeepCacheSDHelper(pipe=self._model)
helper.set_params(cache_interval=3, cache_branch_id=0)
helper.enable()
except:
pass
# Recommended if your computer has < 64 GB of RAM
self._model.enable_attention_slicing()
self._apply_lora()
Expand Down

0 comments on commit 7ff4245

Please sign in to comment.