-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Speedup model loading by 4-5x ⚡ #11904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7a9c448
8385f45
9e4873b
20b1155
b776aaa
e364dfd
ea446b1
e736b09
4c81c96
591655e
582af9b
a6ee660
bbbc4c0
39f0850
58fcfdc
b0552bb
275e470
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,5 +184,14 @@ def get_device(): | |
def empty_device_cache(device_type: Optional[str] = None): | ||
if device_type is None: | ||
device_type = get_device() | ||
if device_type in ["cpu"]: | ||
return | ||
device_mod = getattr(torch, device_type, torch.cuda) | ||
device_mod.empty_cache() | ||
|
||
|
||
def device_synchronize(device_type: Optional[str] = None): | ||
if device_type is None: | ||
device_type = get_device() | ||
device_mod = getattr(torch, device_type, torch.cuda) | ||
device_mod.synchronize() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess all different backends ought to have this method. Just flagging. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. afaik, synchronize should be available on all devices. Just the empty_cache function required a special check because it would fail if device was cpu |
Uh oh!
There was an error while loading. Please reload this page.