mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-18 05:44:31 +08:00
Fix memory leak in full_images_datamanager.py (#3375)
* Fix memory leak in full_images_datamanager.py * remove trailing space * follow-up remove some deepcopy --------- Co-authored-by: J.Y. <132313008+jb-ye@users.noreply.github.com> Co-authored-by: Jianbo Ye <jianboye@amazon.com>
This commit is contained in:
1 file changed
+6
-2
@@ -315,7 +315,7 @@ class FullImageDatamanager(DataManager, Generic[TDataset]):
|
||||
Pretends to be the dataloader for evaluation, it returns a list of (camera, data) tuples
|
||||
"""
|
||||
image_indices = [i for i in range(len(self.eval_dataset))]
|
||||
data = deepcopy(self.cached_eval)
|
||||
data = [d.copy() for d in self.cached_eval]
|
||||
_cameras = deepcopy(self.eval_dataset.cameras).to(self.device)
|
||||
cameras = []
|
||||
for i in image_indices:
|
||||
@@ -350,6 +350,9 @@ class FullImageDatamanager(DataManager, Generic[TDataset]):
|
||||
self.train_unseen_cameras = self.sample_train_cameras()
|
||||
|
||||
data = self.cached_train[image_idx]
|
||||
# We're going to copy to make sure we don't mutate the cached dictionary.
|
||||
# This can cause a memory leak: https://github.com/nerfstudio-project/nerfstudio/issues/3335
|
||||
data = data.copy()
|
||||
data["image"] = data["image"].to(self.device)
|
||||
|
||||
assert len(self.train_cameras.shape) == 1, "Assumes single batch dimension"
|
||||
@@ -375,7 +378,8 @@ class FullImageDatamanager(DataManager, Generic[TDataset]):
|
||||
# Make sure to re-populate the unseen cameras list if we have exhausted it
|
||||
if len(self.eval_unseen_cameras) == 0:
|
||||
self.eval_unseen_cameras = [i for i in range(len(self.eval_dataset))]
|
||||
data = deepcopy(self.cached_eval[image_idx])
|
||||
data = self.cached_eval[image_idx]
|
||||
data = data.copy()
|
||||
data["image"] = data["image"].to(self.device)
|
||||
assert len(self.eval_dataset.cameras.shape) == 1, "Assumes single batch dimension"
|
||||
camera = self.eval_dataset.cameras[image_idx : image_idx + 1].to(self.device)
|
||||
|
||||
Reference in new issue
Block a user