Skip to content

UnboundLocalError: local variable 'any_on_epoch' referenced before assignment in prediction loop #20472

@farhadrgh

Description

@farhadrgh

Bug description

UnboundLocalError raises when using the predict method with return_predictions=False.

This is due to any_on_epoch not being defined if data_fetcher is an instance of _DataLoaderIterDataFetcher.

What version are you seeing the problem on?

v2.4

How to reproduce the bug

No response

Error messages and logs

UnboundLocalError: local variable 'any_on_epoch' referenced before assignment

Environment

Current environment
#- PyTorch Lightning Version (e.g., 2.4.0):
#- PyTorch Version (e.g., 2.4):
#- Python version (e.g., 3.12):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):

More info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions