Open MathiasBaumgartinger opened 3 days ago
After some debugging, I found that indeed, the batches were not on the GPU during the different steps. When I add .to(self.device)
to the batch['image']
and batch['mask']
accesses (see: https://github.com/microsoft/torchgeo/blob/main/torchgeo/trainers/segmentation.py), the pipeline executes without errors.
AFAIK, this should not be necessary, as a pl.Trainer
with a pl.LightningDataModule
and pl.LightningModule
should guarantee these are on the same device via the transfer_batch_to_device
function. And obviously, those are are being called as I do get an output.
EDIT: Tagging @adamjstewart as this might be related to torchgeo
Hit this too. Not sure how significant it is that the batch is a dict
Bug description
Hi there! I have previously created my first
LightningDataModule
. More specifically, aNonGeoDataModule
which inherits from there (see torchgeo-fork. Interestingly, when I try to run this module I getRuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same or input should be a MKLDNN tensor and weight is a dense tensor
. Even more intersting is the fact, that if I override thetransfer_batch_to_device
like:I get the output
It happens during the validation step (lightning/pytorch/strategies/strategy.py", line 411).
What version are you seeing the problem on?
v2.4
How to reproduce the bug
Error messages and logs
Environment
Current environment
``` ----------------------------------------------------------- Python Version: 3.10.4 PyTorch Version: 2.4.1 Cuda is available version: 12.4 Torch built with CUDA: True cuDNN Version: 90100 cuDNN Enabled: True cuDNN available: True Device: cuda Accelerator: gpu lightning 2.4.0 lightning-utilities 0.11.9 pytorch-lightning 2.4.0 ## conda env name: torchgeo channels: - pytorch - nvidia - conda-forge - defaults dependencies: - python=3.10 - pytorch-cuda=12.4 - pytorch=2.4 - torchgeo=0.6.0 - tensorboard=2.17 ----------------------------------------------------------- ```More info
No response