SalesforceAIResearch / uni2ts

[ICML2024] Unified Training of Universal Time Series Forecasting Transformers
Apache License 2.0
755 stars 70 forks source link

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 1 month ago

Mr-kunyuan commented 1 month ago

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

lukc12138 commented 1 month ago

I got the same problem, did you solve it?

Mr-kunyuan commented 1 month ago

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

It hasn't been solved yet.

lukc12138 commented 1 month ago

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

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 commented 1 month ago

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

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 commented 1 month ago

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