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
chenpangpang
transformers
Commits
11c49ed2
Unverified
Commit
11c49ed2
authored
Dec 29, 2022
by
Harsh Trivedi
Committed by
GitHub
Dec 29, 2022
Browse files
Load the state dict on CPU to prevent unnecessary GPU memory surge (#20920)
load the state dict on cpu.
parent
0b686a8a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+1
-1
No files found.
src/transformers/modeling_utils.py
View file @
11c49ed2
...
@@ -382,7 +382,7 @@ def load_sharded_checkpoint(model, folder, strict=True):
...
@@ -382,7 +382,7 @@ def load_sharded_checkpoint(model, folder, strict=True):
raise
RuntimeError
(
error_message
)
raise
RuntimeError
(
error_message
)
for
shard_file
in
shard_files
:
for
shard_file
in
shard_files
:
state_dict
=
torch
.
load
(
os
.
path
.
join
(
folder
,
shard_file
))
state_dict
=
torch
.
load
(
os
.
path
.
join
(
folder
,
shard_file
)
,
map_location
=
"cpu"
)
model
.
load_state_dict
(
state_dict
,
strict
=
False
)
model
.
load_state_dict
(
state_dict
,
strict
=
False
)
# Make sure memory is fred before we load the next state dict.
# Make sure memory is fred before we load the next state dict.
...
...
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