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

Loading weights from local directory Exception ignored in: <generator object PyTorchPredictor.predict at 0x7fe3a1d23a40> Traceback (most recent call last): File "/root/miniconda3/lib/python3.12/site-packages/gluonts/torch/model/predictor.py", line 89, in predict File "/root/miniconda3/lib/python3.12/site-packages/torch/autograd/grad_mode.py", line 84, in __exit__ TypeError: 'NoneType' object is not callable #87

Open
Mr-kunyuan opened this issue Jul 15, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Mr-kunyuan
Copy link

Describe the bug
I encountered the following problem when running the sample program
"Loading weights from local directory
Exception ignored in: <generator object PyTorchPredictor.predict at 0x7fe3a1d23a40>
Traceback (most recent call last):
The File "/ root/miniconda3 / lib/python3.12 / site - packages/gluonts/torch/model/predictor. Py", line 89, in predict
The File "/ root/miniconda3 / lib/python3.12 / site - packages/torch/autograd/grad_mode py", line 84, in exit
TypeError: 'NoneType' object is not callable '.
How to solve it?

Environment
Python version: 3.12.2
PyTorch version: 2.3.1+cu118

@Mr-kunyuan Mr-kunyuan added the bug Something isn't working label Jul 15, 2024
@lukc12138
Copy link

I got the same problem, did you solve it?

@Mr-kunyuan
Copy link
Author

我遇到了同样的问题,你解决了吗?

It hasn't been solved yet.

@lukc12138
Copy link

我遇到了同样的问题,你解决了吗?

It hasn't been solved yet.

I solved this problem by modifying this file: .../site-packages/gluonts/torch/model/predictor.py
just ignore the exception by the code below

try:
            with torch.no_grad():
                yield from self.forecast_generator(
                    inference_data_loader=inference_data_loader,
                    prediction_net=self.prediction_net,
                    input_names=self.input_names,
                    output_transform=self.output_transform,
                    num_samples=num_samples,
                )
        except :
            pass

and it worked.

@Mr-kunyuan
Copy link
Author

我遇到了同样的问题,你解决了吗?

It hasn't been solved yet.

I solved this problem by modifying this file: .../site-packages/gluonts/torch/model/predictor.py just ignore the exception by the code below

try:
            with torch.no_grad():
                yield from self.forecast_generator(
                    inference_data_loader=inference_data_loader,
                    prediction_net=self.prediction_net,
                    input_names=self.input_names,
                    output_transform=self.output_transform,
                    num_samples=num_samples,
                )
        except :
            pass

and it worked.

It worked. Thank you.

@rhenningkf
Copy link

I ran into this too. My fix is ...

In .../site-packages/torch/autograd/grad_mode.py, add the following if at line 84:

Screenshot from 2024-07-17 18-18-21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants