MCPcopy Index your code
hub / github.com/OpenGVLab/InternVL / throughput

Function throughput

classification/main_deepspeed.py:204–222  ·  view source on GitHub ↗
(data_loader, model, logger)

Source from the content-addressed store, hash-verified

202
203@torch.no_grad()
204def throughput(data_loader, model, logger):
205 model.eval()
206
207 for idx, (images, _) in enumerate(data_loader):
208 images = images.cuda(non_blocking=True)
209 batch_size = images.shape[0]
210 for i in range(50):
211 model(images)
212 torch.cuda.synchronize()
213 logger.info(f'throughput averaged with 30 times')
214 tic1 = time.time()
215 for i in range(30):
216 model(images)
217 torch.cuda.synchronize()
218 tic2 = time.time()
219 logger.info(
220 f'batch_size {batch_size} throughput {30 * batch_size / (tic2 - tic1)}'
221 )
222 return
223
224
225def train_epoch(config, model, criterion, data_loader, optimizer, epoch, mixup_fn, lr_scheduler, model_ema=None):

Callers 1

evalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected