Catalyst

Learn how to log Catalyst runs to Neptune.

What will you get with this integration?

Catalyst is a PyTorch framework for Deep Learning R&D. It is built with three main requirements in mind: reproducibility, rapid experimentation, and codebase reuse. Catalyst is a part of the PyTorch Ecosystem.

Neptune is integrated with Catalyst, so that you can automatically log:

  • metrics,

  • hparams (hyper-parameters),

  • images,

  • artifacts (videos, audio, model checkpoints, files, etc.),

  • hardware consumption statistics,

  • stdout and stderr logs,

  • training code and git commit information.

TL;DR for the Catalyst users

This section is for Catalyst users who are familiar with loggers, like CSV logger or TensorBoard logger. If you haven't worked with Catalyst loggers before, jump to the "Where to start?" section below.

Catalyst has a unified way of logging metadata, by using Loggers. NeptuneLogger is part of the Catalyst library.

So all you need to do to start logging is to create NeptuneLogger and pass it to the runner:

Create NeptuneLogger instance

from catalyst import dl
# Create NeptuneLogger
neptune_logger = dl.NeptuneLogger(
project="common/catalyst-integration",
tags=["pretraining", "retina"],
)

You need to pass project to NeptuneLogger(), to inform logger where to log the metadata. There are more parameters to customize logger behavior, check Catalyst docs for more details.

Pass neptune_logger to the Runner

Now, you can add neptune_logger to the runner, like any other Catalyst logger:

# You can pass it to the SupervisedRunner
my_runner = dl.SupervisedRunner()
my_runner.train(
loggers={"neptune": neptune_logger},
...
)
# You can pass it to the custom Runner
class CustomRunner(dl.IRunner):
...
def get_loggers(self):
return {
"console": dl.ConsoleLogger(),
"neptune": neptune_logger
}
runner = CustomRunner().run()

NeptuneLogger is now ready

Setup of the NeptuneLogger is done. You can run your scripts without additional changes and have all metadata logged in the single place for further analysis, comparison and sharing in the team.

Where to start?

To get started with this integration, follow the quickstart below. Then, jump to the "more options" section to learn how to log more metadata with Catalyst custom Runner and custom Callback.

If you want to try it out now you can either:

Quickstart

This quickstart will show you how to:

  • Install required libraries,

  • Connect NeptuneLogger to your Catalyst script to enable automatic logging,

  • Analyse logged metadata and compare some runs.

At the end of this quickstart, you will be able to connect NeptuneLogger to your ML/RL scripts and use it in your experimentation.

Step 1: Install libraries

Before you start, make sure that:

Install neptune-client and catalyst

Depending on your operating system open a terminal or CMD and run this command:

pip install neptune-client catalyst

This integration is tested with catalyst==21.5 and neptune-client==0.9.16.

For more help about neptune-client check:

Install psutil (optional, you can skip it)

If you want to have hardware monitoring logged you should additionally install psutil.

pip
conda
pip
pip install psutil
conda
conda install -c anaconda psutil

Step 2: Add NeptuneLogger to the Catalyst script

Catalyst has a unified way for logging metadata, by using Loggers. Neptune contributed NeptuneLogger which is now part of the Catalyst library.

So all you need to do to start logging is to create NeptuneLogger and pass it to the runner:

Create NeptuneLogger instance

from catalyst import dl
# Create NeptuneLogger
neptune_logger = dl.NeptuneLogger(
project="common/catalyst-integration",
)

You need to pass project to NeptuneLogger(), to inform it where to log metadata. There are more parameters to customize logger behavior, check Catalyst docs for more details.

Once NeptuneLogger is created it will output link to the run to the stdout. It will look like this: https://app.neptune.ai/common/catalyst-integration/e/CATALYST-1486

Pass neptune_logger to the Runner

Now, you can add neptune_logger to the Runner. Example below use SupervisedRunner as an example:

from catalyst import dl
# Create runner
my_runner = dl.SupervisedRunner()
my_runner.train(
loggers={"neptune": neptune_logger},
...
)

At this point neptune_logger is ready.

Remember that you can check entire example:

Step 3: Run the script and analyze logged metadata in the Neptune UI

NeptuneLogger instance is ready. Run your script and have all metadata logged in the single place for further analysis, comparison and sharing in the team.

python main.py

Go to the run link and explore metadata (metrics, hparams, model checkpoint) that were logged. Example run: https://app.neptune.ai/common/catalyst-integration/e/CATALYST-1486

Example run

How to ask for help?

Please visit the Getting help page. Everything regarding support is there:

Other pages you may like

You may also find the following pages useful: