无法在没有GPU的情况下加载darts v0.22.0模型

huangapple go评论106阅读模式
英文:

Unable to load darts v0.22.0 model without GPU

问题

我已经使用darts v0.22.0几个月了。我在一个GPU机器上训练了我的模型,并通过model.save()保存了它。现在当我尝试在仅有CPU的机器上部署它时,我使用了以下代码将模型放到CPU上。

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

模型加载正常,但当我使用model.historical_forecasts()时,显示以下转储信息。似乎模型仍在寻找GPU。

我尝试使用darts v0.23.1来加载模型,但它报错了关于darts encoders包的更改。

如果我找不到解决方法,我的很多工作将会丢失。对任何帮助都将非常感激。

谢谢

Adeel

英文:

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!

答案1

得分: 0

这个问题的解决方案可以在这里找到:

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

英文:

The solution to this problem can be found here:

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

huangapple
  • 本文由 发表于 2023年3月7日 06:28:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75656421.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定