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

Example not working on ubuntu noble python 3.12.x #1678

Open
sudeepgoyal75 opened this issue Feb 9, 2025 · 2 comments
Open

Example not working on ubuntu noble python 3.12.x #1678

sudeepgoyal75 opened this issue Feb 9, 2025 · 2 comments

Comments

@sudeepgoyal75
Copy link

Prerequisites

  1. Install ubuntu noble 24.04
  2. create python virtual env for version 3.12
  3. source virtual environment 3.12
  4. pip install neuralprophet
  5. Copy example from https://neuralprophet.com/contents.html#features in test.py
  6. python test.py
  7. it will fail with below errors. however if you try with 3.10 it will work
    metrics = m.fit(df)
@nizamuddinsyed
Copy link

@sudeepgoyal75 please post the error you are encountering and how does your dataframe looks.

@sudeepgoyal75
Copy link
Author

Same code works fine with python 3.10.0 which is taken from https://neuralprophet.com/quickstart.html

Version

python -V
Python 3.12.3

code

import pandas as pd

#data_location = "https://raw.githubusercontent.com/ourownstory/neuralprophet-data/main/datasets/"

df = pd.read_csv("wp_log_peyton_manning.csv")

m = NeuralProphet()
#m.set_plotting_backend("plotly-static")  # show plots correctly in jupyter notebooks
metrics = m.fit(df)`

error

Importing plotly failed. Interactive plots will not work.
WARNING - (NP.forecaster.fit) - When Global modeling with local normalization, metrics are displayed in normalized scale.
WARNING - (py.warnings._showwarnmsg) - /home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/neuralprophet/df_utils.py:1152: FutureWarning: Series.view is deprecated and will be removed in a future version. Use ``astype`` as an alternative to change the dtype.
  converted_ds = pd.to_datetime(ds_col, utc=True).view(dtype=np.int64)

INFO - (NP.df_utils._infer_frequency) - Major frequency D corresponds to 99.966% of the data.
INFO - (NP.df_utils._infer_frequency) - Dataframe freq automatically defined as D
INFO - (NP.config.init_data_params) - Setting normalization to global as only one dataframe provided for training.
INFO - (NP.utils.set_auto_seasonalities) - Disabling daily seasonality. Run NeuralProphet with daily_seasonality=True to override this.
INFO - (NP.config.set_auto_batch_epoch) - Auto-set batch_size to 64
INFO - (NP.config.set_auto_batch_epoch) - Auto-set epochs to 80
WARNING - (NP.config.set_lr_finder_args) - Learning rate finder: The number of batches (47) is too small than the required number                     for the learning rate finder (237). The results might not be optimal.
Finding best initial lr: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████| 237/237 [00:04<00:00, 52.56it/s]
Traceback (most recent call last):
  File "/home/sudeep.goyal/tf/llm/weather/doc.py", line 10, in <module>
    metrics = m.fit(df)
              ^^^^^^^^^
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/neuralprophet/forecaster.py", line 1062, in fit
    metrics_df = self._train(
                 ^^^^^^^^^^^^
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/neuralprophet/forecaster.py", line 2802, in _train
    lr_finder = self.trainer.tuner.lr_find(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/tuner/tuning.py", line 267, in lr_find
    self.trainer.fit(model, train_dataloaders, val_dataloaders, datamodule)
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/trainer/trainer.py", line 608, in fit
    call._call_and_handle_interrupt(
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/trainer/call.py", line 38, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/trainer/trainer.py", line 650, in _fit_impl
    self._run(model, ckpt_path=self.ckpt_path)
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/trainer/trainer.py", line 1097, in _run
    self._call_callback_hooks("on_fit_start")
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/trainer/trainer.py", line 1394, in _call_callback_hooks
    fn(self, self.lightning_module, *args, **kwargs)
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/callbacks/lr_finder.py", line 122, in on_fit_start
    self.lr_find(trainer, pl_module)
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/callbacks/lr_finder.py", line 107, in lr_find
    self.optimal_lr = lr_find(
                      ^^^^^^^^
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/tuner/lr_finder.py", line 273, in lr_find
    trainer._checkpoint_connector.restore(ckpt_path)
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/trainer/connectors/checkpoint_connector.py", line 224, in restore
    self.resume_start(checkpoint_path)
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/trainer/connectors/checkpoint_connector.py", line 90, in resume_start
    loaded_checkpoint = self.trainer.strategy.load_checkpoint(checkpoint_path)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/pytorch_lightning/strategies/strategy.py", line 359, in load_checkpoint
    return self.checkpoint_io.load_checkpoint(checkpoint_path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/lightning_fabric/plugins/io/torch_io.py", line 86, in load_checkpoint
    return pl_load(path, map_location=map_location)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/lightning_fabric/utilities/cloud_io.py", line 51, in _load
    return torch.load(f, map_location=map_location)  # type: ignore[arg-type]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sudeep.goyal/tf/myenv/lib/python3.12/site-packages/torch/serialization.py", line 1470, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
        (1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
        WeightsUnpickler error: Unsupported global: GLOBAL neuralprophet.configure.ConfigSeasonality was not an allowed global by default. Please use `torch.serialization.add_safe_globals([ConfigSeasonality])` or the `torch.serialization.safe_globals([ConfigSeasonality])` context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

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