Skip to content

Commit

Permalink
Fix hanging metrics tests (#5134)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadejsv authored Dec 14, 2020
1 parent eb9cb3c commit 69123af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions tests/metrics/regression/test_ssim.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ def _sk_metric(preds, target, data_range, multichannel):
class TestSSIM(MetricTester):
atol = 6e-5

# TODO: for some reason this test hangs with ddp=True
# @pytest.mark.parametrize("ddp", [True, False])
@pytest.mark.parametrize("ddp", [False])
@pytest.mark.parametrize("ddp", [True, False])
@pytest.mark.parametrize("dist_sync_on_step", [True, False])
def test_ssim(self, preds, target, multichannel, ddp, dist_sync_on_step):
self.run_class_metric_test(
Expand Down
10 changes: 6 additions & 4 deletions tests/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

from pytorch_lightning.metrics import Metric

try:
set_start_method("spawn")
except RuntimeError:
pass

NUM_PROCESSES = 2
NUM_BATCHES = 10
BATCH_SIZE = 32
Expand Down Expand Up @@ -165,10 +170,7 @@ def setup_class(self):
"""Setup the metric class. This will spawn the pool of workers that are
used for metric testing and setup_ddp
"""
try:
set_start_method("spawn")
except RuntimeError:
pass

self.poolSize = NUM_PROCESSES
self.pool = Pool(processes=self.poolSize)
self.pool.starmap(setup_ddp, [(rank, self.poolSize) for rank in range(self.poolSize)])
Expand Down

0 comments on commit 69123af

Please sign in to comment.