From acc089a449866fd71bc26975ca9ba67d1abfbb5a Mon Sep 17 00:00:00 2001 From: Kai Zhang Date: Sun, 1 Nov 2020 18:08:33 -0500 Subject: [PATCH] throw exception for inappropriate usage --- ddp_train_nerf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ddp_train_nerf.py b/ddp_train_nerf.py index fbcf4f1..a217fdc 100644 --- a/ddp_train_nerf.py +++ b/ddp_train_nerf.py @@ -121,6 +121,11 @@ def sample_pdf(bins, weights, N_samples, det=False): def render_single_image(rank, world_size, models, ray_sampler, chunk_size): ##### parallel rendering of a single image ray_batch = ray_sampler.get_all() + + if (ray_batch['ray_d'].shape[0] // world_size) * world_size != ray_batch['ray_d'].shape[0]: + raise Exception('Number of pixels in the image is not divisible by the number of GPUs!\n\t# pixels: {}\n\t# GPUs: {}'.format(ray_batch['ray_d'].shape[0], + world_size)) + # split into ranks; make sure different processes don't overlap rank_split_sizes = [ray_batch['ray_d'].shape[0] // world_size, ] * world_size rank_split_sizes[-1] = ray_batch['ray_d'].shape[0] - sum(rank_split_sizes[:-1])