lightning/pl_examples/basic_examples
Carlos Mocholí e16d4fbdee
CI code cleaning (#7615)
2021-05-21 11:35:12 +00:00
..
README.md CI code cleaning (#7615) 2021-05-21 11:35:12 +00:00
__init__.py changes examples to pl_examples for name connflict 2019-10-19 00:41:17 +02:00
autoencoder.py Default `seed_everything(workers=True)` in the `LightningCLI` (#7504) 2021-05-13 12:18:03 +02:00
backbone_image_classifier.py Default `seed_everything(workers=True)` in the `LightningCLI` (#7504) 2021-05-13 12:18:03 +02:00
conv_sequential_example.py [docs] Update Bolts link (#6743) 2021-03-30 22:52:59 +05:30
dali_image_classifier.py Default `seed_everything(workers=True)` in the `LightningCLI` (#7504) 2021-05-13 12:18:03 +02:00
mnist_datamodule.py Reuse _TORCHVISION_AVAILABLE (#6976) 2021-04-13 18:33:32 +02:00
profiler_example.py release 1.3.0 (#7404) 2021-05-06 15:05:35 -04:00
simple_image_classifier.py Default `seed_everything(workers=True)` in the `LightningCLI` (#7504) 2021-05-13 12:18:03 +02:00

README.md

Basic Examples

Use these examples to test how lightning works.

MNIST

Trains MNIST where the model is defined inside the LightningModule.

# cpu
python simple_image_classifier.py

# gpus (any number)
python simple_image_classifier.py --trainer.gpus 2

# dataparallel
python simple_image_classifier.py --trainer.gpus 2 --trainer.accelerator 'dp'

MNIST with DALI

The MNIST example above using NVIDIA DALI. Requires NVIDIA DALI to be installed based on your CUDA version, see here.

python dali_image_classifier.py

Image classifier

Generic image classifier with an arbitrary backbone (ie: a simple system)

# cpu
python backbone_image_classifier.py

# gpus (any number)
python backbone_image_classifier.py --trainer.gpus 2

# dataparallel
python backbone_image_classifier.py --trainer.gpus 2 --trainer.accelerator 'dp'

Autoencoder

Showing the power of a system... arbitrarily complex training loops

# cpu
python autoencoder.py

# gpus (any number)
python autoencoder.py --trainer.gpus 2

# dataparallel
python autoencoder.py --trainer.gpus 2 --trainer.accelerator 'dp'

Multi-node example

This demo launches a job using 2 GPUs on 2 different nodes (4 GPUs total). To run this demo do the following:

  1. Log into the jumphost node of your SLURM-managed cluster.
  2. Create a conda environment with Lightning and a GPU PyTorch version.
  3. Choose a script to submit