Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Add support for Lightning 1.8 + Fixes for the CI (#1479)
Browse files Browse the repository at this point in the history
* Add requires(icevision) for loading data (icevision integration)

* checking if issues were there for pl 1.7.7

* Update requirements.txt

* Pin sahi version

* list dependencies as a separate step

* Sahi pin to 0.8.19 for serve

* try torchscript instead of torch.jit.trace

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update golang

* 1.17

* 1.17.9

* rollback some unrequired changes

* @rohitgr7 suggested this

* @rohitgr7 suggested this

* lr_schedulers to lr_scheduler_configs

* check if PL greater than equal to 1.8.0

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add PL check for 1.8.0

* Start 3.8 to 3.10

* Move back to 3.7 to 3.9

* Remove _notebooks as it's unused

* Revert "Remove _notebooks as it's unused"

This reverts commit 30deeb6.

* fix lr_scheduler_configs usage

* try fixing jsonnet (go < 1.17)

* Try installing 1.17

* Try installing 1.17

* Try installing 1.17

* Try installing 1.17

* Try installing 1.17

* Skip mac os 12 (flaky)

* skip flaky test on Mac

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update with num_devices instead of tpu_cores

* Add CHANGELOG
  • Loading branch information
krshrimali authored Nov 5, 2022
1 parent 58ee3a7 commit 6e95997
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 10 deletions.
6 changes: 5 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ references:
jobs:

TPU-tests:
executor:
name: go/default
tag: '1.17'
docker:
- image: circleci/python:3.7
environment:
Expand All @@ -94,7 +97,8 @@ jobs:
- CHECK_SPEEP: 5
steps:
- checkout
- go/install
- go/install:
version: "1.17"
- *checkout_ml_testing
- gcp-gke/install
- gcp-gke/update-kubeconfig-with-credentials:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ jobs:
pip install torch>=1.7.1
pip install '.[${{ join(matrix.topic, ',') }}]' --upgrade $flag --find-links https://download.pytorch.org/whl/cpu/torch_stable.html
pip install '.[test]' --upgrade
pip list
shell: bash

- name: Install vissl
Expand All @@ -128,7 +127,7 @@ jobs:
if: contains( matrix.topic , 'serve' )
run: |
sudo apt-get install libsndfile1
pip install '.[all,audio]' icevision effdet --upgrade
pip install '.[all,audio]' icevision sahi==0.8.19 effdet --upgrade
- name: Install audio test dependencies
if: contains( matrix.topic , 'audio' )
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Fixed

- Fixed compatibility with `lightning==1.8.0` ([#1479](https://github.com/Lightning-AI/lightning-flash/pull/1479))
- Fixed the error message to suggest installing `icevision`, if it's not found while loading data ([#1474](https://github.com/Lightning-AI/lightning-flash/pull/1474))
- Fixed compatibility with `torchmetrics==1.10.0` ([#1469](https://github.com/Lightning-AI/lightning-flash/pull/1469))

Expand Down
2 changes: 1 addition & 1 deletion docs/source/general/training.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ Flash tasks supports many advanced training functionalities out-of-the-box, such
.. code-block:: python
# Train on TPUs
flash.Trainer(tpu_cores=8)
flash.Trainer(accelerator="tpu", num_devices=8)
You can add to the flash Trainer any argument from the Lightning trainer! Learn more about the Lightning Trainer `here <https://pytorch-lightning.readthedocs.io/en/stable/common/trainer.html>`_.
4 changes: 2 additions & 2 deletions flash/core/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ def predict(
Returns a list of dictionaries, one for each provided dataloader containing their respective predictions.
"""
# Note: Prediction on TPU device with multi cores is not supported yet
if isinstance(self.accelerator, TPUAccelerator) and self.tpu_cores > 1:
if isinstance(self.accelerator, TPUAccelerator) and self.num_devices > 1:
raise NotImplementedError(
f"Prediction on TPU device with multi-cores (requested cores: {self.tpu_cores}) is not supported yet."
f"Prediction on TPU device with multi-cores (requested cores: {self.num_devices}) is not supported yet."
)
model = model or self.lightning_module
output_transform = getattr(model, "_output_transform", None) or OutputTransform()
Expand Down
1 change: 1 addition & 0 deletions flash/core/utilities/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class Image:
_PL_GREATER_EQUAL_1_4_0 = compare_version("pytorch_lightning", operator.ge, "1.4.0")
_PL_GREATER_EQUAL_1_5_0 = compare_version("pytorch_lightning", operator.ge, "1.5.0")
_PL_GREATER_EQUAL_1_6_0 = compare_version("pytorch_lightning", operator.ge, "1.6.0rc0")
_PL_GREATER_EQUAL_1_8_0 = compare_version("pytorch_lightning", operator.ge, "1.8.0")
_PANDAS_GREATER_EQUAL_1_3_0 = compare_version("pandas", operator.ge, "1.3.0")
_ICEVISION_GREATER_EQUAL_0_11_0 = compare_version("icevision", operator.ge, "0.11.0")
_TM_GREATER_EQUAL_0_7_0 = compare_version("torchmetrics", operator.ge, "0.7.0")
Expand Down
1 change: 1 addition & 0 deletions requirements/datatype_image_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ fiftyone
classy_vision
vissl>=0.1.5
icevision>=0.8
sahi >=0.8.19,<0.11.0
icedata
effdet
kornia>=0.5.1
Expand Down
6 changes: 5 additions & 1 deletion tests/core/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
_GRAPH_TESTING,
_IMAGE_AVAILABLE,
_IMAGE_TESTING,
_PL_GREATER_EQUAL_1_8_0,
_TABULAR_TESTING,
_TEXT_TESTING,
_TORCH_OPTIMIZER_AVAILABLE,
Expand Down Expand Up @@ -471,7 +472,10 @@ def train_dataloader(self):

assert task.get_num_training_steps() == batch_count
assert isinstance(trainer.optimizers[0], torch.optim.Adadelta)
assert isinstance(trainer.lr_schedulers[0]["scheduler"], torch.optim.lr_scheduler.LambdaLR)
if _PL_GREATER_EQUAL_1_8_0:
assert isinstance(trainer.lr_scheduler_configs[0].scheduler, torch.optim.lr_scheduler.LambdaLR)
else:
assert isinstance(trainer.lr_schedulers[0]["scheduler"], torch.optim.lr_scheduler.LambdaLR)


@pytest.mark.skipif(not _CORE_TESTING, reason="Not testing core.")
Expand Down
1 change: 1 addition & 0 deletions tests/examples/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"template.py",
marks=[
pytest.mark.skipif(not _CORE_TESTING, reason="Not testing core."),
pytest.mark.skipif(os.name == "posix", reason="Flaky on Mac OS (CI)"),
pytest.mark.skipif(sys.version_info >= (3, 9), reason="Undiagnosed segmentation fault in 3.9"),
],
),
Expand Down
4 changes: 1 addition & 3 deletions tests/helpers/task_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ def _test_jit_trace(self, tmpdir):
path = os.path.join(tmpdir, "test.pt")

model = self.instantiated_task
trainer = self.instantiated_trainer
model.eval()

model.trainer = trainer
model = torch.jit.trace(model, self.example_forward_input)
model = model.to_torchscript(method="trace", example_inputs=self.example_forward_input)

torch.jit.save(model, path)
model = torch.jit.load(path)
Expand Down

0 comments on commit 6e95997

Please sign in to comment.