:orphan:
.. _sphx_glr_examples_apps:
Application Examples
====================
This contains the example applications that demonstrates how to use TorchX
for various styles of applications (e.g. single node, distributed, etc).
These apps can be launched by themselves or part of a pipeline. It is important
to note that TorchX's job is to launch the apps. You'll notice that the apps
are implemented without any TorchX imports.
See the Pipelines Examples for how to use the components in a pipeline.
Prerequisites
################
Before executing examples, install TorchX and dependencies necessary to run examples:
```
$ pip install torchx
$ git clone https://github.com/pytorch/torchx.git
$ cd torchx/examples/apps
$ TORCHX_VERSION=$(torchx --version | sed 's/torchx-//')
$ git checkout v$TORCHX_VERSION
$ pip install -r dev-requirements.txt
```
.. raw:: html
.. _sphx_glr_examples_apps_compute_world_size:
Compute World Size Example
############################
This is a minimal "hello world" style example application that uses
PyTorch Distributed to compute the world size. It is a minimal example
in that it initializes the ``torch.distributed`` process group and
performs a single collective operation (all_reduce) which is enough to
validate the infrastructure and scheduler setup.
This example is compatible with the ``dist.ddp``. To run from CLI:
.. code-block:: shell-session
$ cd $torchx-git-repo-root/torchx/examples/apps
$ torchx run dist.ddp --script compute_world_size/main.py -j 1x2
.. raw:: html
.. only:: html
.. figure:: /examples_apps/compute_world_size/images/thumb/sphx_glr_main_thumb.png
:alt: Compute World Size Example
:ref:`sphx_glr_examples_apps_compute_world_size_main.py`
.. raw:: html
.. toctree::
:hidden:
/examples_apps/compute_world_size/main
.. raw:: html
.. _sphx_glr_examples_apps_datapreproc:
Data Preprocessing Example
##########################
This is a simple TorchX app that downloads some data via HTTP, normalizes the
images via torchvision and then reuploads it via fsspec.
This examples has two Python files: the app which actually does the
preprocessing and the component definition which can be used with TorchX to
launch the app.
.. raw:: html
.. only:: html
.. figure:: /examples_apps/datapreproc/images/thumb/sphx_glr_datapreproc_thumb.png
:alt: Data Preprocessing App Example
:ref:`sphx_glr_examples_apps_datapreproc_datapreproc.py`
.. raw:: html
.. toctree::
:hidden:
/examples_apps/datapreproc/datapreproc
.. raw:: html
.. _sphx_glr_examples_apps_lightning:
Lightning Trainer Example
#########################################
This example consists of model training and interpretability apps that uses
PyTorch Lightning. The apps have shared logic so are split across several files.
The trainer and interpret apps do not have any TorchX-isms and are
simply torchvision and Captum applications. TorchX helps you run these
applications on various schedulers and localhost.
The trainer app is a distributed data parallel style application and is launched
with the `dist.ddp` built-in. The interpret app is a single node application
and is launched as a regular python process with the `utils.python` built-in.
For instructions on how to run these apps with TorchX refer to the documentations
in their respective main modules: `train.py` and `interpret.py`.
.. raw:: html
.. only:: html
.. figure:: /examples_apps/lightning/images/thumb/sphx_glr_profiler_thumb.png
:alt: Simple Logging Profiler
:ref:`sphx_glr_examples_apps_lightning_profiler.py`
.. raw:: html
.. toctree::
:hidden:
/examples_apps/lightning/profiler
.. raw:: html
.. only:: html
.. figure:: /examples_apps/lightning/images/thumb/sphx_glr_interpret_thumb.png
:alt: Model Interpretability Example
:ref:`sphx_glr_examples_apps_lightning_interpret.py`
.. raw:: html
.. toctree::
:hidden:
/examples_apps/lightning/interpret
.. raw:: html
.. only:: html
.. figure:: /examples_apps/lightning/images/thumb/sphx_glr_model_thumb.png
:alt: Tiny ImageNet Model
:ref:`sphx_glr_examples_apps_lightning_model.py`
.. raw:: html
.. toctree::
:hidden:
/examples_apps/lightning/model
.. raw:: html
.. only:: html
.. figure:: /examples_apps/lightning/images/thumb/sphx_glr_train_thumb.png
:alt: Trainer Example
:ref:`sphx_glr_examples_apps_lightning_train.py`
.. raw:: html
.. toctree::
:hidden:
/examples_apps/lightning/train
.. raw:: html
.. only:: html
.. figure:: /examples_apps/lightning/images/thumb/sphx_glr_data_thumb.png
:alt: Trainer Datasets Example
:ref:`sphx_glr_examples_apps_lightning_data.py`
.. raw:: html
.. toctree::
:hidden:
/examples_apps/lightning/data
.. raw:: html
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-gallery
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download all examples in Python source code: examples_apps_python.zip /home/runner/work/torchx/torchx/docs/source/examples_apps/examples_apps_python.zip>`
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download all examples in Jupyter notebooks: examples_apps_jupyter.zip /home/runner/work/torchx/torchx/docs/source/examples_apps/examples_apps_jupyter.zip>`
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_