Skip to content

Commit ef9861d

Browse files
committed
Merge branch 'master' into tests/hpc_load_deprecation
2 parents da5b79c + 374fae5 commit ef9861d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1294
-807
lines changed

.azure-pipelines/gpu-tests.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
image: "pytorchlightning/pytorch_lightning:base-cuda-py3.7-torch1.8"
3333
# default shm size is 64m. Increase it to avoid:
3434
# 'Error while creating shared memory: unhandled system error, NCCL version 2.7.8'
35-
options: "--runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all --shm-size=256m"
35+
options: "--runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all --shm-size=512m"
3636

3737
workspace:
3838
clean: all
@@ -73,6 +73,8 @@ jobs:
7373
7474
- bash: |
7575
bash tests/special_tests.sh
76+
env:
77+
PL_USE_MOCKED_MNIST: "1"
7678
displayName: 'Testing: special'
7779
7880
- bash: |
@@ -99,10 +101,6 @@ jobs:
99101
testRunTitle: '$(Agent.OS) - $(Build.BuildNumber)[$(Agent.JobName)] - Python $(python.version)'
100102
condition: succeededOrFailed()
101103

102-
- bash: |
103-
python -m pytest benchmarks -v --maxfail=2 --durations=0
104-
displayName: 'Testing: benchmarks'
105-
106104
- script: |
107105
set -e
108106
python -m pytest pl_examples -v --maxfail=2 --durations=0
@@ -112,3 +110,7 @@ jobs:
112110
env:
113111
PL_USE_MOCKED_MNIST: "1"
114112
displayName: 'Testing: examples'
113+
114+
- bash: |
115+
python -m pytest benchmarks -v --maxfail=2 --durations=0
116+
displayName: 'Testing: benchmarks'

CHANGELOG.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
3333

3434

3535
- Progress tracking
36-
* Added dataclasses for progress tracking ([#6603](https://github.com/PyTorchLightning/pytorch-lightning/pull/6603), [#7574](https://github.com/PyTorchLightning/pytorch-lightning/pull/7574), [#8140](https://github.com/PyTorchLightning/pytorch-lightning/pull/8140))
36+
* Added dataclasses for progress tracking ([#6603](https://github.com/PyTorchLightning/pytorch-lightning/pull/6603), [#7574](https://github.com/PyTorchLightning/pytorch-lightning/pull/7574), [#8140](https://github.com/PyTorchLightning/pytorch-lightning/pull/8140), [#8362](https://github.com/PyTorchLightning/pytorch-lightning/pull/8362))
3737
* Add `{,load_}state_dict` to the progress tracking dataclasses ([#8140](https://github.com/PyTorchLightning/pytorch-lightning/pull/8140))
38-
* Connect the progress tracking dataclasses to the loops ([#8244](https://github.com/PyTorchLightning/pytorch-lightning/pull/8244))
38+
* Connect the progress tracking dataclasses to the loops ([#8244](https://github.com/PyTorchLightning/pytorch-lightning/pull/8244), [#8362](https://github.com/PyTorchLightning/pytorch-lightning/pull/8362))
3939

4040

4141
- Added support for passing a `LightningDataModule` positionally as the second argument to `trainer.{validate,test,predict}` ([#7431](https://github.com/PyTorchLightning/pytorch-lightning/pull/7431))
@@ -92,6 +92,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
9292
- Fault-tolerant training
9393
* Added `{,load_}state_dict` to `ResultCollection` ([#7948](https://github.com/PyTorchLightning/pytorch-lightning/pull/7948))
9494
* Added `{,load_}state_dict` to `Loops` ([#8197](https://github.com/PyTorchLightning/pytorch-lightning/pull/8197))
95+
* Set `Loop.restarting=False` at the end of the first iteration ([#8362](https://github.com/PyTorchLightning/pytorch-lightning/pull/8362))
96+
* Save the loops state with the checkpoint (opt-in) ([#8362](https://github.com/PyTorchLightning/pytorch-lightning/pull/8362))
97+
* Save a checkpoint to restore the state on exception (opt-in) ([#8362](https://github.com/PyTorchLightning/pytorch-lightning/pull/8362))
98+
* Added `state_dict` and `load_state_dict` utilities for `CombinedLoader` + utilities for dataloader ([#8364](https://github.com/PyTorchLightning/pytorch-lightning/pull/8364))
9599

96100

97101
- Added `rank_zero_only` to `LightningModule.log` function ([#7966](https://github.com/PyTorchLightning/pytorch-lightning/pull/7966))
@@ -402,8 +406,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
402406
- Removed deprecated `optimizer` argument in `LightningModule.manual_backward()`; Toggling optimizers in manual optimization should be done using `LightningModule.{un}toggle_optimizer()` ([#8287](https://github.com/PyTorchLightning/pytorch-lightning/pull/8287))
403407

404408

405-
406-
407409
### Fixed
408410

409411
- Fixed `lr_scheduler` checkpointed state by calling `update_lr_schedulers` before saving checkpoints ([#7877](https://github.com/PyTorchLightning/pytorch-lightning/pull/7877))
@@ -469,6 +471,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
469471
- Fixed missing call to `LightningModule.untoggle_optimizer` in training loop when running gradient accumulation with multiple optimizers ([#8284](https://github.com/PyTorchLightning/pytorch-lightning/pull/8284))
470472

471473

474+
- Fixed `move_data_to_device` to return the batch if the object `to` function didn't return `self` ([#8433](https://github.com/PyTorchLightning/pytorch-lightning/pull/8433))
475+
476+
472477
- Fixed progress bar updates for Pod Training ([#8258](https://github.com/PyTorchLightning/pytorch-lightning/pull/8258))
473478

474479

pl_examples/__init__.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
from urllib.error import HTTPError
32

43
from six.moves import urllib
54

@@ -14,16 +13,8 @@
1413
_PACKAGE_ROOT = os.path.dirname(_EXAMPLES_ROOT)
1514
_DATASETS_PATH = os.path.join(_PACKAGE_ROOT, 'Datasets')
1615

17-
_TORCHVISION_MNIST_AVAILABLE = not bool(os.environ.get("PL_USE_MOCKED_MNIST", False))
1816
_DALI_AVAILABLE = _module_available("nvidia.dali")
1917

20-
if _TORCHVISION_MNIST_AVAILABLE:
21-
try:
22-
from torchvision.datasets.mnist import MNIST
23-
MNIST(_DATASETS_PATH, download=True)
24-
except HTTPError:
25-
_TORCHVISION_MNIST_AVAILABLE = False
26-
2718
LIGHTNING_LOGO = """
2819
####
2920
###########

pl_examples/basic_examples/autoencoder.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,13 @@
2424
from torch.utils.data import DataLoader, random_split
2525

2626
import pytorch_lightning as pl
27-
from pl_examples import _DATASETS_PATH, _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo
27+
from pl_examples import _DATASETS_PATH, cli_lightning_logo
28+
from pl_examples.basic_examples.mnist_datamodule import MNIST
2829
from pytorch_lightning.utilities.cli import LightningCLI
2930
from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE
3031

3132
if _TORCHVISION_AVAILABLE:
3233
from torchvision import transforms
33-
if _TORCHVISION_MNIST_AVAILABLE:
34-
from torchvision.datasets import MNIST
35-
else:
36-
from tests.helpers.datasets import MNIST
3734

3835

3936
class LitAutoEncoder(pl.LightningModule):

pl_examples/basic_examples/backbone_image_classifier.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,13 @@
2424
from torch.utils.data import DataLoader, random_split
2525

2626
import pytorch_lightning as pl
27-
from pl_examples import _DATASETS_PATH, _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo
27+
from pl_examples import _DATASETS_PATH, cli_lightning_logo
28+
from pl_examples.basic_examples.mnist_datamodule import MNIST
2829
from pytorch_lightning.utilities.cli import LightningCLI
2930
from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE
3031

3132
if _TORCHVISION_AVAILABLE:
3233
from torchvision import transforms
33-
if _TORCHVISION_MNIST_AVAILABLE:
34-
from torchvision.datasets import MNIST
35-
else:
36-
from tests.helpers.datasets import MNIST
3734

3835

3936
class Backbone(torch.nn.Module):

pl_examples/basic_examples/dali_image_classifier.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@
2222
from torch.utils.data import random_split
2323

2424
import pytorch_lightning as pl
25-
from pl_examples import _DALI_AVAILABLE, _DATASETS_PATH, _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo
25+
from pl_examples import _DALI_AVAILABLE, _DATASETS_PATH, cli_lightning_logo
26+
from pl_examples.basic_examples.mnist_datamodule import MNIST
2627
from pytorch_lightning.utilities.cli import LightningCLI
2728
from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE
2829

2930
if _TORCHVISION_AVAILABLE:
3031
from torchvision import transforms
31-
if _TORCHVISION_MNIST_AVAILABLE:
32-
from torchvision.datasets import MNIST
33-
else:
34-
from tests.helpers.datasets import MNIST
3532

3633
if _DALI_AVAILABLE:
3734
from nvidia.dali import __version__ as dali_version

pl_examples/basic_examples/mnist_datamodule.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,31 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import os
1415
import platform
1516
from typing import Optional
17+
from urllib.error import HTTPError
1618
from warnings import warn
1719

1820
from torch.utils.data import DataLoader, random_split
1921

20-
from pl_examples import _DATASETS_PATH, _TORCHVISION_MNIST_AVAILABLE
22+
from pl_examples import _DATASETS_PATH
2123
from pytorch_lightning import LightningDataModule
2224
from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE
2325

2426
if _TORCHVISION_AVAILABLE:
2527
from torchvision import transforms as transform_lib
28+
29+
_TORCHVISION_MNIST_AVAILABLE = not bool(os.getenv("PL_USE_MOCKED_MNIST", False))
2630
if _TORCHVISION_MNIST_AVAILABLE:
27-
from torchvision.datasets import MNIST
28-
else:
31+
try:
32+
from torchvision.datasets import MNIST
33+
MNIST(_DATASETS_PATH, download=True)
34+
except HTTPError as e:
35+
print(f"Error {e} downloading `torchvision.datasets.MNIST`")
36+
_TORCHVISION_MNIST_AVAILABLE = False
37+
if not _TORCHVISION_MNIST_AVAILABLE:
38+
print("`torchvision.datasets.MNIST` not available. Using our hosted version")
2939
from tests.helpers.datasets import MNIST
3040

3141

pl_examples/domain_templates/generative_adversarial_net.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,15 @@
2828
import torch.nn.functional as F # noqa
2929
from torch.utils.data import DataLoader
3030

31-
from pl_examples import _TORCHVISION_MNIST_AVAILABLE, cli_lightning_logo
31+
from pl_examples import cli_lightning_logo
32+
from pl_examples.basic_examples.mnist_datamodule import MNIST
3233
from pytorch_lightning.core import LightningDataModule, LightningModule
3334
from pytorch_lightning.trainer import Trainer
3435
from pytorch_lightning.utilities.imports import _TORCHVISION_AVAILABLE
3536

3637
if _TORCHVISION_AVAILABLE:
3738
import torchvision
3839
from torchvision import transforms
39-
if _TORCHVISION_MNIST_AVAILABLE:
40-
from torchvision.datasets import MNIST
41-
else:
42-
from tests.helpers.datasets import MNIST
4340

4441

4542
class Generator(nn.Module):

pytorch_lightning/callbacks/gradient_accumulation_scheduler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(self, scheduling: Dict[int, int]):
7272
self.epochs = sorted(scheduling.keys())
7373

7474
def going_to_accumulate_grad_batches(self):
75-
return any([v > 1 for v in self.scheduling.values()])
75+
return any(v > 1 for v in self.scheduling.values())
7676

7777
def on_train_epoch_start(self, trainer, pl_module):
7878
epoch = trainer.current_epoch

pytorch_lightning/core/datamodule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
from torch.utils.data import DataLoader, Dataset, IterableDataset
2121

2222
from pytorch_lightning.core.hooks import CheckpointHooks, DataHooks
23+
from pytorch_lightning.core.mixins import HyperparametersMixin
2324
from pytorch_lightning.utilities import rank_zero_deprecation
2425
from pytorch_lightning.utilities.argparse import add_argparse_args, from_argparse_args, get_init_arguments_and_types
25-
from pytorch_lightning.utilities.hparams_mixin import HyperparametersMixin
2626

2727

2828
class LightningDataModule(CheckpointHooks, DataHooks, HyperparametersMixin):

0 commit comments

Comments
 (0)