Loading several checkpoints gives and error #13449
Unanswered
YerePhy
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 1 comment 1 reply
-
|
It looks to me that the issue is specific to neither "several checkpoints" nor PyTorch Lightning itself.
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am trying to load several checkpoints in order to make an ensemble-like prediction. The
__init__of myLightningModulelooks like this:class VolumetricSemanticSegmentator(pl.LightningModule): """ LightningModule for semantic segmentation models enhanced with MONAI features. """ def __init__( self, architecture: torch.nn.Module, loss: torch.nn.Module, optimizer: str, optimizer_configuration: Mapping[str, Any], postprocessing: monai.transforms.Compose, sw_kwargs_test: Mapping[str, Any], patch_predictor: Callable[[torch.Tensor, torch.nn.Module], torch.Tensor], scheduler: Optional[str] = None, scheduler_configuration: Optional[Mapping[str, Any]] = None, metrics_evaluator: Evaluator = None, train_gpu_augmentations: Optional[torch.nn.Module] = None, ) -> None: super(VolumetricSemanticSegmentator, self).__init__() self.architechture = architecture self.loss = loss self.scheduler = scheduler self.scheduler_configuration = scheduler_configuration self.optimizer = optimizer self.optimizer_configuration = optimizer_configuration self.patch_predictor = patch_predictor self.postprocessing = postprocessing self.metrics_evaluator = metrics_evaluator self.sw_kwargs_test = sw_kwargs_test self.train_gpu_augmentations = train_gpu_augmentations self.save_hyperparameters(ignore=["architecture", "loss"])I'm loading the checkpoints like this:
model_cls = cfg.lightningmodule.pop("lightningmodule_type") # here, I get the model class (no an instance) model_cfg = cfg.lightningmodule # here, I get all the arguments in the __init__ instantiated (with facebook-hydra) # here, I load the checkpoints with the parameters # of the `__init__` method, I can't do # `model_cls.load_from_checkpoint(p)` because # it throws a missing parameters error ensemble = [model_cls.load_from_checkpoint(p, **model_cfg) for p in ckpts]Then I get the following error:
Exception ignored in: Traceback (most recent call last): File "/home/yere/anaconda3/envs/iq_segmentator/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1358, in __del__ self._shutdown_workers() File "/home/yere/anaconda3/envs/iq_segmentator/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1289, in _shutdown_workers if not self._shutdown: AttributeError: '_MultiProcessingDataLoaderIter' object has no attribute '_shutdown' Exception ignored in: Traceback (most recent call last): File "/home/yere/anaconda3/envs/iq_segmentator/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1358, in __del__ self._shutdown_workers() File "/home/yere/anaconda3/envs/iq_segmentator/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1289, in _shutdown_workers if not self._shutdown: AttributeError: '_MultiProcessingDataLoaderIter' object has no attribute '_shutdown'Very weird since I am not using any dataloader in my script.
Beta Was this translation helpful? Give feedback.
All reactions