英文:
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
这个问题的解决方案可以在这里找到:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论