reduced mem on train; figuring out memory leak on visualizer

This commit is contained in:
evonneng committed 2022-09-13 03:22:07 +00:00
1 parent 416669d808
commit 139da13be8
12 files changed
+22 -13

No files matched your search

+6 -3
View File
@@ -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)