mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-16 21:03:46 +08:00
reduced mem on train; figuring out memory leak on visualizer
This commit is contained in:
1 parent
416669d808
commit
139da13be8
12 files changed
+22
-13
No files matched your search
@@ -19,12 +19,12 @@ Miscellaneous helper code.
|
||||
import hashlib
|
||||
import json
|
||||
from math import floor, log
|
||||
from typing import Any, Callable, Dict, Union
|
||||
from typing import Any, Callable, Dict, List, Optional, Union
|
||||
|
||||
import torch
|
||||
|
||||
|
||||
def get_dict_to_torch(stuff: Any, device: Union[torch.device, str] = "cpu"):
|
||||
def get_dict_to_torch(stuff: Any, device: Union[torch.device, str] = "cpu", exclude: Optional[List[str]] = None):
|
||||
"""Set everything in the dict to the specified torch device.
|
||||
|
||||
Args:
|
||||
@@ -32,7 +32,10 @@ def get_dict_to_torch(stuff: Any, device: Union[torch.device, str] = "cpu"):
|
||||
"""
|
||||
if isinstance(stuff, dict):
|
||||
for k, v in stuff.items():
|
||||
stuff[k] = get_dict_to_torch(v, device)
|
||||
if exclude and k in exclude:
|
||||
stuff[k] = v
|
||||
else:
|
||||
stuff[k] = get_dict_to_torch(v, device)
|
||||
return stuff
|
||||
if isinstance(stuff, torch.Tensor):
|
||||
return stuff.to(device)
|
||||
|
||||
Reference in new issue
Block a user