Skip to content

Commit

Permalink
perf(train): specify num_workers in DataLoader (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
34j authored Apr 13, 2023
1 parent c2bfb29 commit 6042164
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/so_vits_svc_fork/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
from logging import getLogger
from multiprocessing import freeze_support
from pathlib import Path
from typing import Literal

Expand Down Expand Up @@ -819,4 +820,6 @@ def train_cluster(
)


cli()
if __name__ == "__main__":
freeze_support()
cli()
5 changes: 4 additions & 1 deletion src/so_vits_svc_fork/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import warnings
from logging import getLogger
from multiprocessing import cpu_count
from pathlib import Path
from typing import Any

Expand Down Expand Up @@ -41,16 +42,18 @@ def __init__(self, hparams: Any):
self.val_dataset = TextAudioDataset(self.__hparams, is_validation=True)

def train_dataloader(self):
# since dataset just reads data from a file, set num_workers to 0
return DataLoader(
self.train_dataset,
# pin_memory=False,
num_workers=min(cpu_count(), 4),
batch_size=self.__hparams.train.batch_size,
collate_fn=self.collate_fn,
)

def val_dataloader(self):
return DataLoader(
self.val_dataset,
# pin_memory=False,
batch_size=1,
collate_fn=self.collate_fn,
)
Expand Down

0 comments on commit 6042164

Please sign in to comment.