Shortcuts

Remote Filesystems

PyTorch Lightning enables working with data from a variety of filesystems, including local filesystems and several cloud storage providers such as S3 on AWS, GCS on Google Cloud, or ADL on Azure.

This applies to saving and writing checkpoints, as well as for logging. Working with different filesystems can be accomplished by appending a protocol like “s3:/” to file paths for writing and reading data.

# `default_root_dir` is the default path used for logs and checkpoints
trainer = Trainer(default_root_dir="s3://my_bucket/data/")
trainer.fit(model)

You could pass custom paths to loggers for logging data.

from pytorch_lightning.loggers import TensorBoardLogger

logger = TensorBoardLogger(save_dir="s3://my_bucket/logs/")

trainer = Trainer(logger=logger)
trainer.fit(model)

Additionally, you could also resume training with a checkpoint stored at a remote filesystem.

trainer = Trainer(default_root_dir=tmpdir, max_steps=3)
trainer.fit(model, ckpt_path="s3://my_bucket/ckpts/classifier.ckpt")

PyTorch Lightning uses fsspec internally to handle all filesystem operations.

The most common filesystems supported by Lightning are:

  • Local filesystem: file:// - It’s the default and doesn’t need any protocol to be used. It’s installed by default in Lightning.

  • Amazon S3: s3:// - Amazon S3 remote binary store, using the library s3fs. Run pip install fsspec[s3] to install it.

  • Google Cloud Storage: gcs:// or gs:// - Google Cloud Storage, using gcsfs. Run pip install fsspec[gcs] to install it.

  • Microsoft Azure Storage: adl://, abfs:// or az:// - Microsoft Azure Storage, using adlfs. Run pip install fsspec[adl] to install it.

  • Hadoop File System: hdfs:// - Hadoop Distributed File System. This uses PyArrow as the backend. Run pip install fsspec[hdfs] to install it.

You could learn more about the available filesystems with:

from fsspec.registry import known_implementations

print(known_implementations)

You could also look into CheckpointIO Plugin for more details on how to customize saving and loading checkpoints.

Read the Docs v: latest
Versions
latest
stable
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.10
1.5.9
1.5.8
1.5.7
1.5.6
1.5.5
1.5.4
1.5.3
1.5.2
1.5.1
1.5.0
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.8
1.3.7
1.3.6
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.10
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.8
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.10.0
0.9.0
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.3
0.4.9
future-structure
Downloads
html
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.