Skip to content

Commit

Permalink
fix(train): support ddp in Windows (gloo backend) (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
34j authored Apr 19, 2023
1 parent 7be08f5 commit bcb0507
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/so_vits_svc_fork/train.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import os
import warnings
from logging import getLogger
from multiprocessing import cpu_count
Expand All @@ -10,6 +11,7 @@
import torch
from lightning.pytorch.accelerators import MPSAccelerator, TPUAccelerator
from lightning.pytorch.loggers import TensorBoardLogger
from lightning.pytorch.strategies.ddp import DDPStrategy
from lightning.pytorch.tuner import Tuner
from torch.cuda.amp import autocast
from torch.nn import functional as F
Expand Down Expand Up @@ -75,7 +77,13 @@ def train(

datamodule = VCDataModule(hparams)
strategy = (
"ddp_find_unused_parameters_true" if torch.cuda.device_count() > 1 else "auto"
(
"ddp_find_unused_parameters_true"
if os.name != "nt"
else DDPStrategy(find_unused_parameters=True, process_group_backend="gloo")
)
if torch.cuda.device_count() > 1
else "auto"
)
LOG.info(f"Using strategy: {strategy}")
trainer = pl.Trainer(
Expand Down

0 comments on commit bcb0507

Please sign in to comment.