Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
a1c8ad88
Commit
a1c8ad88
authored
Dec 10, 2022
by
MrCheeze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unload depth model if medvram/lowvram enabled
parent
685f9631
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
lowvram.py
modules/lowvram.py
+7
-5
No files found.
modules/lowvram.py
View file @
a1c8ad88
...
@@ -55,18 +55,20 @@ def setup_for_low_vram(sd_model, use_medvram):
...
@@ -55,18 +55,20 @@ def setup_for_low_vram(sd_model, use_medvram):
if
hasattr
(
sd_model
.
cond_stage_model
,
'model'
):
if
hasattr
(
sd_model
.
cond_stage_model
,
'model'
):
sd_model
.
cond_stage_model
.
transformer
=
sd_model
.
cond_stage_model
.
model
sd_model
.
cond_stage_model
.
transformer
=
sd_model
.
cond_stage_model
.
model
# remove
three big modules, cond, first_stage
, and unet from the model and then
# remove
four big modules, cond, first_stage, depth (if applicable)
, and unet from the model and then
# send the model to GPU. Then put modules back. the modules will be in CPU.
# send the model to GPU. Then put modules back. the modules will be in CPU.
stored
=
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
sd_model
.
model
stored
=
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
getattr
(
sd_model
,
'depth_model'
,
None
),
sd_model
.
model
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
sd_model
.
model
=
None
,
None
,
None
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
sd_model
.
depth_model
,
sd_model
.
model
=
None
,
None
,
None
,
None
sd_model
.
to
(
devices
.
device
)
sd_model
.
to
(
devices
.
device
)
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
sd_model
.
model
=
stored
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
sd_model
.
depth_model
,
sd_model
.
model
=
stored
# register hooks for those the first t
wo
models
# register hooks for those the first t
hree
models
sd_model
.
cond_stage_model
.
transformer
.
register_forward_pre_hook
(
send_me_to_gpu
)
sd_model
.
cond_stage_model
.
transformer
.
register_forward_pre_hook
(
send_me_to_gpu
)
sd_model
.
first_stage_model
.
register_forward_pre_hook
(
send_me_to_gpu
)
sd_model
.
first_stage_model
.
register_forward_pre_hook
(
send_me_to_gpu
)
sd_model
.
first_stage_model
.
encode
=
first_stage_model_encode_wrap
sd_model
.
first_stage_model
.
encode
=
first_stage_model_encode_wrap
sd_model
.
first_stage_model
.
decode
=
first_stage_model_decode_wrap
sd_model
.
first_stage_model
.
decode
=
first_stage_model_decode_wrap
if
sd_model
.
depth_model
:
sd_model
.
depth_model
.
register_forward_pre_hook
(
send_me_to_gpu
)
parents
[
sd_model
.
cond_stage_model
.
transformer
]
=
sd_model
.
cond_stage_model
parents
[
sd_model
.
cond_stage_model
.
transformer
]
=
sd_model
.
cond_stage_model
if
hasattr
(
sd_model
.
cond_stage_model
,
'model'
):
if
hasattr
(
sd_model
.
cond_stage_model
,
'model'
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment