Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignite/handlers/checkpoint.py:16: DeprecationWarning concerning TorchScript #3323

Closed
sjiang95 opened this issue Jan 9, 2025 · 3 comments
Closed

Comments

@sjiang95
Copy link
Contributor

sjiang95 commented Jan 9, 2025

🐛 Bug description

ignite logger triggers the following warning everytime (maybe) a new logger instance is created.

ignite/handlers/checkpoint.py:16: DeprecationWarning: `TorchScript` support for functional optimizers is deprecated and will be removed in a future PyTorch release. Consider using the `torch.compile` optimizer instead.
  from torch.distributed.optim import ZeroRedundancyOptimizer

Reproduce

Below is a snippet to reproduce it

import torch
import ignite


def foo(i, logger):
    pass


if __name__ == "__main__":
    logger = ignite.utils.setup_logger()
    torch.multiprocessing.spawn(foo, args=(logger,), nprocs=2)

stdout:

/opt/conda/lib/python3.11/site-packages/ignite/handlers/checkpoint.py:16: DeprecationWarning: `TorchScript` support for functional optimizers is deprecated and will be removed in a future PyTorch release. Consider using the `torch.compile` optimizer instead.
  from torch.distributed.optim import ZeroRedundancyOptimizer
/opt/conda/lib/python3.11/site-packages/ignite/handlers/checkpoint.py:16: DeprecationWarning: `TorchScript` support for functional optimizers is deprecated and will be removed in a future PyTorch release. Consider using the `torch.compile` optimizer instead.
  from torch.distributed.optim import ZeroRedundancyOptimizer
/opt/conda/lib/python3.11/site-packages/ignite/handlers/checkpoint.py:16: DeprecationWarning: `TorchScript` support for functional optimizers is deprecated and will be removed in a future PyTorch release. Consider using the `torch.compile` optimizer instead.
  from torch.distributed.optim import ZeroRedundancyOptimizer

where the first warning is triggered by ignite.utils.setup_logger(), and the rest nprocs times warnings are triggered when the sub processes are initialized.

After some trials, I found that the warning is triggered once ignite.handlers.checkpoint is imported, for which simply importing ignite also leads to the warning.

$ python -c "import ignite"
/opt/conda/lib/python3.11/site-packages/ignite/handlers/checkpoint.py:16: DeprecationWarning: `TorchScript` support for functional optimizers is deprecated and will be removed in a future PyTorch release. Consider using the `torch.compile` optimizer instead.
  from torch.distributed.optim import ZeroRedundancyOptimizer
$ python -c "import ignite.handlers"
/opt/conda/lib/python3.11/site-packages/ignite/handlers/checkpoint.py:16: DeprecationWarning: `TorchScript` support for functional optimizers is deprecated and will be removed in a future PyTorch release. Consider using the `torch.compile` optimizer instead.
  from torch.distributed.optim import ZeroRedundancyOptimizer

Expect

Avoid the annoying warning message.

Environment

  • PyTorch Version: 2.5.1_cuda12.4_cudnn9_0
  • Ignite Version: 0.5.1
  • OS: Linux and Windows
  • How you installed Ignite: conda install -c pytorch ignite
  • Python version: 3.12, 3.11
  • Any other relevant information:

relevant issues

#3318
Project-MONAI/MONAI#8060
Project-MONAI/MONAI#8017 (comment)

@sjiang95
Copy link
Contributor Author

sjiang95 commented Jan 9, 2025

This is fixed by
pytorch/pytorch#140889.

@sjiang95 sjiang95 closed this as completed Jan 9, 2025
@vfdev-5
Copy link
Collaborator

vfdev-5 commented Jan 9, 2025

Thanks for digging into the issue @sjiang95 !
Hopefully, new version pytorch wont raise this warning anymore. Nightly version should be silent, to confirm...

@sjiang95
Copy link
Contributor Author

sjiang95 commented Jan 9, 2025

I have confirmed the issue has been solved in pytorch nightly build.
Test env is
pytorch: 2.7.0.dev20250108+cu126
ignite: 0.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants