gaussian-splatting
gaussian-splatting copied to clipboard
add GPU number and lazy load img to GPU
trafficstars
hello,
- I add a gpu number argument in
ModelParamsclass. - In order to save GPU memory, I cancelled the loading of img to GPU when creating the camera, and delayed loading img to GPU during training. This greatly saves GPU memory. I tested it in RTX2080ti and less than 2GB during initial training, even if trained to 30k, less than 5GB.
This is a great improvement in memory usage, this should be merged into main branch. @Snosixtyboo
typo, should be device with a c --data_device cpu
typo, should be device with a c
--data_device cpu
tks for ur careful check
maybe we can reduce more usage of memory by lazy call function loadCam.
def lazy_call(f, *args, **kwargs):
return lambda: f(*args, **kwargs)
def cameraList_from_camInfos(cam_infos, resolution_scale, args, lazy_load):
camera_list = []
# pdb.set_trace()
for id, c in enumerate(cam_infos):
if lazy_load:
camera_list.append(lazy_call(loadCam, args, id, c, resolution_scale))
else:
camera_list.append(loadCam(args, id, c, resolution_scale))
return camera_list`
In function 'cameraList_from_camInfos', we can delay executing loadCam and execute it in 'training'.
# Pick a random Camera
if not viewpoint_stack:
viewpoint_stack = scene.getTrainCameras().copy()
viewpoint_cam = viewpoint_stack.pop(randint(0, len(viewpoint_stack)-1))
if scene.lazy_load:
viewpoint_cam = viewpoint_cam()