mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-12 12:40:20 +08:00
clear skipping tests (#1285)
* clear skipping tests * fix simple/multi GPU * review: simplify
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
import tests.base.utils as tutils
|
||||
from pytorch_lightning import Trainer
|
||||
@@ -10,13 +11,11 @@ from tests.base import (
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skipif(not torch.cuda.is_available(), reason="test requires GPU machine")
|
||||
def test_amp_single_gpu(tmpdir):
|
||||
"""Make sure DDP + AMP work."""
|
||||
tutils.reset_seed()
|
||||
|
||||
if not tutils.can_run_gpu_test():
|
||||
return
|
||||
|
||||
hparams = tutils.get_default_hparams()
|
||||
model = LightningTestModel(hparams)
|
||||
|
||||
@@ -33,13 +32,11 @@ def test_amp_single_gpu(tmpdir):
|
||||
|
||||
|
||||
@pytest.mark.spawn
|
||||
@pytest.mark.skipif(not torch.cuda.is_available(), reason="test requires GPU machine")
|
||||
def test_no_amp_single_gpu(tmpdir):
|
||||
"""Make sure DDP + AMP work."""
|
||||
tutils.reset_seed()
|
||||
|
||||
if not tutils.can_run_gpu_test():
|
||||
return
|
||||
|
||||
hparams = tutils.get_default_hparams()
|
||||
model = LightningTestModel(hparams)
|
||||
|
||||
@@ -58,11 +55,9 @@ def test_no_amp_single_gpu(tmpdir):
|
||||
assert result == 1
|
||||
|
||||
|
||||
@pytest.mark.skipif(torch.cuda.device_count() < 2, reason="test requires multi-GPU machine")
|
||||
def test_amp_gpu_ddp(tmpdir):
|
||||
"""Make sure DDP + AMP work."""
|
||||
if not tutils.can_run_gpu_test():
|
||||
return
|
||||
|
||||
tutils.reset_seed()
|
||||
tutils.set_random_master_port()
|
||||
|
||||
@@ -82,11 +77,9 @@ def test_amp_gpu_ddp(tmpdir):
|
||||
|
||||
|
||||
@pytest.mark.spawn
|
||||
@pytest.mark.skipif(torch.cuda.device_count() < 2, reason="test requires multi-GPU machine")
|
||||
def test_amp_gpu_ddp_slurm_managed(tmpdir):
|
||||
"""Make sure DDP + AMP work."""
|
||||
if not tutils.can_run_gpu_test():
|
||||
return
|
||||
|
||||
tutils.reset_seed()
|
||||
|
||||
# simulate setting slurm flags
|
||||
@@ -150,13 +143,11 @@ def test_cpu_model_with_amp(tmpdir):
|
||||
|
||||
|
||||
@pytest.mark.spawn
|
||||
@pytest.mark.skipif(torch.cuda.device_count() < 2, reason="test requires multi-GPU machine")
|
||||
def test_amp_gpu_dp(tmpdir):
|
||||
"""Make sure DP + AMP work."""
|
||||
tutils.reset_seed()
|
||||
|
||||
if not tutils.can_run_gpu_test():
|
||||
return
|
||||
|
||||
model, hparams = tutils.get_default_model()
|
||||
trainer_options = dict(
|
||||
default_save_path=tmpdir,
|
||||
|
||||
Reference in New Issue
Block a user