pytorchpytorch-lightningu8darts

Unable to load darts v0.22.0 model without GPU


I have been using darts v0.22.0 for the last few months. I had trained my model on a GPU machine and saved it via model.save(). Now when I'm trying to deploy it on a CPU only machine, I used the following code to place the model on CPU.

  model = torch.load(home + "model.txt.ckpt", map_location=torch.device('cpu'))

The model loads ok but when I use model.historical_forecasts() the below dump is shown. It seems the model is still looking for a GPU.

I tried using darts v0.23.1 to load the model but it gives error about a change in the darts encoders package.

A lot of my work will be lost if I don't find a way around this. Any help will be highly appreciated.

Thanks

Adeel

No supported gpu backend found! Traceback (most recent call last):\n File "/code/central/temp/onykz6rv/968/model/darts_class.py", line 171, in run_testing\n preds = model.historical_forecasts(series=lst_test[t], past_covariates=lst_test_cov[t], retrain=False, forecast_horizon=horizon)\n File "/root/miniconda3/lib/python3.9/site-packages/darts/utils/utils.py", line 172, in sanitized_method\n return method_to_sanitize(self, *only_args.values(), **only_kwargs)\n File "/root/miniconda3/lib/python3.9/site-packages/darts/models/forecasting/forecasting_model.py", line 500, in historical_forecasts\n forecast = self._predict_wrapper(\n File "/root/miniconda3/lib/python3.9/site-packages/darts/models/forecasting/forecasting_model.py", line 1228, in _predict_wrapper\n return self.predict(\n File "/root/miniconda3/lib/python3.9/site-packages/darts/utils/torch.py", line 112, in decorator\n return decorated(self, *args, **kwargs)\n File "/root/miniconda3/lib/python3.9/site-packages/darts/models/forecasting/torch_forecasting_model.py", line 1051, in predict\n predictions = self.predict_from_dataset(\n File "/root/miniconda3/lib/python3.9/site-packages/darts/utils/torch.py", line 112, in decorator\n return decorated(self, *args, **kwargs)\n File "/root/miniconda3/lib/python3.9/site-packages/darts/models/forecasting/torch_forecasting_model.py", line 1178, in predict_from_dataset\n
self._setup_trainer(trainer=trainer, verbose=verbose, epochs=self.n_epochs)\n File "/root/miniconda3/lib/python3.9/site-packages/darts/models/forecasting/torch_forecasting_model.py", line 457, in _setup_trainer\n
self._init_trainer(trainer_params=trainer_params, max_epochs=epochs)\n File "/root/miniconda3/lib/python3.9/site-packages/darts/models/forecasting/torch_forecasting_model.py", line 471, in _init_trainer\n return pl.Trainer(**trainer_params_copy)\n File "/root/miniconda3/lib/python3.9/site-packages/pytorch_lightning/utilities/argparse.py", line 340, in insert_env_defaults\n return fn(self, **kwargs)\n File "/root/miniconda3/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 414, in init\n self._accelerator_connector = AcceleratorConnector(\n File "/root/miniconda3/lib/python3.9/site-packages/pytorch_lightning/trainer/connectors/accelerator_connector.py", line 206, in init\n self._accelerator_flag = self._choose_gpu_accelerator_backend()\n File "/root/miniconda3/lib/python3.9/site-packages/pytorch_lightning/trainer/connectors/accelerator_connector.py", line 512, in _choose_gpu_accelerator_backend\n raise MisconfigurationException("No supported gpu backend found!")\nlightning_lite.utilities.exceptions.MisconfigurationException: No supported gpu backend found!


Solution

  • The solution to this problem can be found here:

    https://github.com/unit8co/darts/issues/1624