Skip to content

Commit

Permalink
Update to pytorch lightning 2.0.2, remove lightning bolts dependency …
Browse files Browse the repository at this point in the history
…and other fixes (#344)

* updated lightning version, removed bolts dependency, fixed umap, updated some python syntax

* remove support for 3.7 and fixed timm import

* fixes

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

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

* Update dali_tests.yml

* Update sphinx-linkcheck.yml

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
vturrisi and pre-commit-ci[bot] authored May 22, 2023
1 parent 6a891ee commit 66cad5b
Show file tree
Hide file tree
Showing 85 changed files with 347 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dali_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: [3.7, 3.8, 3.9]
python: [3.8, 3.9]
os: [ubuntu-latest]

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sphinx-linkcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.7
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: 3.9

- name: python dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: [3.7, 3.8, 3.9]
python: [3.8, 3.9]
os: [ubuntu-latest, windows-latest]

steps:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
def package_list_from_file(file):
"""List up package name (not containing version and extras) from a package list file"""
mocked_packages = []
with open(file, "r") as fp:
with open(file) as fp:
for ln in fp.readlines():
# Example: `tqdm>=4.41.0` => `tqdm`
# `[` is for package with extras
Expand Down
8 changes: 4 additions & 4 deletions docs/source/solo/methods/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ validation_step
.. automethod:: solo.methods.base.BaseMethod.validation_step
:noindex:

validation_epoch_end
on_validation_epoch_end
~~~~~~~~~~~~~~~~~~~~
.. automethod:: solo.methods.base.BaseMethod.validation_epoch_end
.. automethod:: solo.methods.base.BaseMethod.on_validation_epoch_end
:noindex:


Expand Down Expand Up @@ -104,7 +104,7 @@ validation_step
.. automethod:: solo.methods.base.BaseMethod.validation_step
:noindex:

validation_epoch_end
on_validation_epoch_end
~~~~~~~~~~~~~~~~~~~~
.. automethod:: solo.methods.base.BaseMethod.validation_epoch_end
.. automethod:: solo.methods.base.BaseMethod.on_validation_epoch_end
:noindex:
4 changes: 2 additions & 2 deletions docs/source/solo/methods/linear.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ validation_step
.. automethod:: solo.methods.linear.LinearModel.validation_step
:noindex:

validation_epoch_end
on_validation_epoch_end
~~~~~~~~~~~~~~~~~~~~
.. automethod:: solo.methods.linear.LinearModel.validation_epoch_end
.. automethod:: solo.methods.linear.LinearModel.on_validation_epoch_end
:noindex:
9 changes: 5 additions & 4 deletions main_umap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import os
from pathlib import Path

from omegaconf import OmegaConf

from solo.args.umap import parse_args_umap
from solo.data.classification_dataloader import prepare_data
from solo.methods import METHODS
Expand All @@ -38,15 +40,14 @@ def main():
# load arguments
with open(args_path) as f:
method_args = json.load(f)
cfg = OmegaConf.create(method_args)

# build the model
model = (
METHODS[method_args["method"]]
.load_from_checkpoint(ckpt_path, strict=False, **method_args)
.load_from_checkpoint(ckpt_path, strict=False, cfg=cfg)
.backbone
)
model.cuda()

# prepare data
train_loader, val_loader = prepare_data(
args.dataset,
Expand All @@ -55,7 +56,7 @@ def main():
data_format=args.data_format,
batch_size=args.batch_size,
num_workers=args.num_workers,
auto_augment=args.auto_augment,
auto_augment=False,
)

umap = OfflineUMAP()
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
torch>=1.10.0
torchvision>=0.11.1
einops
pytorch-lightning>=1.7.0, <1.9.0
pytorch-lightning==2.0.2
torchmetrics>=0.6.0, <0.12.0
lightning-bolts>=0.6.0
tqdm
wandb
scipy
Expand Down
2 changes: 1 addition & 1 deletion scripts/finetune/imagenet-100/mae.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ devices: [0, 1, 2, 3, 4, 5, 6, 7]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/finetune/imagenet/mae.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ devices: [0, 1, 2, 3, 4, 5, 6, 7]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/barlow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/byol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/deepclusterv2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/dino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/mocov2plus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/mocov3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/mocov3_vit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/nnclr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/ressl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/simclr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/simsiam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/swav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/vibcreg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet-100/vicreg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet/barlow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet/byol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/linear/imagenet/mocov2plus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar-multicrop/swav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/barlow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/byol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/deepclusterv2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/dino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/mae.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/mocov2plus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/mocov3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/nnbyol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/nnclr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/nnsiam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/ressl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/simclr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/simsiam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/supcon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/swav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/vibcreg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/vicreg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/cifar/wmse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ devices: [0]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/custom/byol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ devices: [0, 1]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/imagenet-100-multicrop/byol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ devices: [0, 1]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/imagenet-100-multicrop/simclr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ devices: [0, 1]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/imagenet-100-multicrop/supcon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ devices: [0, 1]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/imagenet-100/barlow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ devices: [0, 1]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/imagenet-100/byol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ devices: [0, 1]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/imagenet-100/deepclusterv2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ devices: [0, 1]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
2 changes: 1 addition & 1 deletion scripts/pretrain/imagenet-100/dino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ devices: [0, 1]
sync_batchnorm: True
accelerator: "gpu"
strategy: "ddp"
precision: 16
precision: 16-mixed
Loading

0 comments on commit 66cad5b

Please sign in to comment.