aim icon indicating copy to clipboard operation
aim copied to clipboard

AimLogger not working with PyTorch lightning

Open gursi26 opened this issue 1 year ago • 1 comments

❓Question

Here is my code for the PyTorch lightning trainer

import lightning as L

trainer = L.Trainer(
    max_epochs=EPOCHS,
    accelerator=DEVICE,
    logger = aim.Run(experiment="trial_exp_lightning")
)
trainer.fit(training_module, train_loader, test_loader)

Upon running this, I get the following error message.

AttributeError: 'Run' object has no attribute 'save_dir'

I have checked previous issues in both the lightning and aim repos and it seems that integration is possible, so im wondering how I should go about fixing this.

gursi26 avatar Jan 09 '24 15:01 gursi26

Hey @gursi26, Aim provides a built-in callback manager specifically designed for PyTorch Lightning. It is highly recommended to utilize this manager to handle all PyTorch Lightning events effectively.

Here's how your code snippet will appear after making those changes:

import lightning as L

aim_logger = AimLogger(
    experiment_name="trial_exp_lightning",
)

trainer = L.Trainer(
    max_epochs=EPOCHS,
    accelerator=DEVICE,
    logger = aim_logger
)
trainer.fit(training_module, train_loader, test_loader)

You can refer for more details on this page: https://aimstack.readthedocs.io/en/latest/quick_start/integrations.html#integration-with-pytorch-lightning

Feel free to share any additional issues you may encounter ☺️

tamohannes avatar Jan 11 '24 13:01 tamohannes