Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
xuwx1
LightX2V
Commits
52f3ffc0
Commit
52f3ffc0
authored
Sep 16, 2025
by
gushiqiao
Committed by
GitHub
Sep 16, 2025
Browse files
[Fix] Fix oom bug (#311)
parent
3c778aee
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
lightx2v/models/networks/wan/audio_model.py
lightx2v/models/networks/wan/audio_model.py
+2
-5
lightx2v/models/networks/wan/model.py
lightx2v/models/networks/wan/model.py
+5
-0
No files found.
lightx2v/models/networks/wan/audio_model.py
View file @
52f3ffc0
...
...
@@ -39,12 +39,9 @@ class WanAudioModel(WanModel):
adapter_offload
=
self
.
config
.
get
(
"cpu_offload"
,
False
)
self
.
adapter_weights_dict
=
load_weights
(
self
.
config
.
adapter_model_path
,
cpu_offload
=
adapter_offload
,
remove_key
=
"audio"
)
if
not
dist
.
is_initialized
():
if
not
dist
.
is_initialized
()
and
not
adapter_offload
:
for
key
in
self
.
adapter_weights_dict
:
# if adapter_offload:
# self.adapter_weights_dict[key] = self.adapter_weights_dict[key].pin_memory()
# else:
self
.
adapter_weights_dict
[
key
]
=
self
.
adapter_weights_dict
[
key
].
pin_memory
().
to
(
"cuda"
)
self
.
adapter_weights_dict
[
key
]
=
self
.
adapter_weights_dict
[
key
].
cuda
()
def
_init_infer_class
(
self
):
super
().
_init_infer_class
()
...
...
lightx2v/models/networks/wan/model.py
View file @
52f3ffc0
import
gc
import
json
import
os
...
...
@@ -253,6 +254,10 @@ class WanModel(CompiledMethodsMixin):
self
.
pre_weight
.
load
(
self
.
original_weight_dict
)
self
.
transformer_weights
.
load
(
self
.
original_weight_dict
)
del
self
.
original_weight_dict
torch
.
cuda
.
empty_cache
()
gc
.
collect
()
def
_load_weights_distribute
(
self
,
weight_dict
,
is_weight_loader
):
global_src_rank
=
0
target_device
=
"cpu"
if
self
.
cpu_offload
else
"cuda"
...
...
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