diff --git a/README.md b/README.md index 08e7587..22e744e 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,8 @@ python train.py -s Space-separated iterations at which the training script saves the Gaussian model, ```7000 30000 ``` by default. #### --quiet Flag to omit any text written to standard out pipe. + #### --data_device + Specify where to put the data on,```cuda``` by default, recommend use ```cpu``` if training on large scale/resolution dataset, will save a lot of VRAM required to train, but slightly slower the training
diff --git a/arguments/__init__.py b/arguments/__init__.py index 4ab86f4..eba1dba 100644 --- a/arguments/__init__.py +++ b/arguments/__init__.py @@ -52,6 +52,7 @@ class ModelParams(ParamGroup): self._images = "images" self._resolution = -1 self._white_background = False + self.data_device = "cuda" self.eval = False super().__init__(parser, "Loading Parameters", sentinel) diff --git a/scene/cameras.py b/scene/cameras.py index b57d351..abf6e52 100644 --- a/scene/cameras.py +++ b/scene/cameras.py @@ -17,7 +17,7 @@ from utils.graphics_utils import getWorld2View2, getProjectionMatrix class Camera(nn.Module): def __init__(self, colmap_id, R, T, FoVx, FoVy, image, gt_alpha_mask, image_name, uid, - trans=np.array([0.0, 0.0, 0.0]), scale=1.0 + trans=np.array([0.0, 0.0, 0.0]), scale=1.0, data_device = "cuda" ): super(Camera, self).__init__() @@ -29,14 +29,21 @@ class Camera(nn.Module): self.FoVy = FoVy self.image_name = image_name - self.original_image = image.clamp(0.0, 1.0).cuda() + try: + self.data_device = torch.device(data_device) + except Exception as e: + print(e) + print(f"[Warning] Custom device {data_device} failed, fallback to default cuda device" ) + self.data_device = torch.device("cuda") + + self.original_image = image.clamp(0.0, 1.0).to(self.data_device) self.image_width = self.original_image.shape[2] self.image_height = self.original_image.shape[1] if gt_alpha_mask is not None: - self.original_image *= gt_alpha_mask.cuda() + self.original_image *= gt_alpha_mask.to(self.data_device) else: - self.original_image *= torch.ones((1, self.image_height, self.image_width), device="cuda") + self.original_image *= torch.ones((1, self.image_height, self.image_width), device=self.data_device) self.zfar = 100.0 self.znear = 0.01 diff --git a/utils/camera_utils.py b/utils/camera_utils.py index 21d762e..1a54d0a 100644 --- a/utils/camera_utils.py +++ b/utils/camera_utils.py @@ -49,7 +49,7 @@ def loadCam(args, id, cam_info, resolution_scale): return Camera(colmap_id=cam_info.uid, R=cam_info.R, T=cam_info.T, FoVx=cam_info.FovX, FoVy=cam_info.FovY, image=gt_image, gt_alpha_mask=loaded_mask, - image_name=cam_info.image_name, uid=id) + image_name=cam_info.image_name, uid=id, data_device=args.data_device) def cameraList_from_camInfos(cam_infos, resolution_scale, args): camera_list = []