Trainer.test() on ddp can not get entire dataset. #5263
Answered
by
carmocca
MarsSu0618
asked this question in
DDP / multi-GPU / multi-node
-
ProblemHi, Everyone. I have some question about ddp. Because I want to write Hope someone can help me to solve it. Because I have to write predict result to file. EnvironmentSample Codeclass ExampleModel(pl.LightningModule):
def __init__(self):
self.original_file = open('/path/to/file', 'a')
def train_step(...):
.....
def test_step(self, batch, batch_idx):
init_ids = batch['init_ids']
attention_mask = batch['attention_mask']
token_type_ids = batch['token_type_ids']
predictions = self.model(init_ids, attention_mask, token_type_ids)
..........
self.original_file.write(convert_ids_to_str(init_ids.cpu().numpy()) + '\t' + str(seg.cpu().numpy()[0]) + '\n')
trainer = pl.Trainer(max_epochs=EPOCH,
gpus=[0,1],
num_nodes=1,
auto_select_gpus=True,
num_sanity_val_steps=0,
accelerator='ddp',
callbacks=[modelcheckpoint_callback, earlystopping_callback])trainer.test(model=model, test_dataloaders=test_dataloader)Hope someone can help or answer how to do it. |
Beta Was this translation helpful? Give feedback.
Answered by
carmocca
Apr 20, 2021
Replies: 1 comment
-
|
Please, check out |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
carmocca
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please, check out
trainer.predict()after 1.3 is released!