Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.83k stars 1.08k forks source link

integration error test_integration_workflows_gan #6594

Closed wyli closed 1 year ago

wyli commented 1 year ago

Describe the bug

https://github.com/Project-MONAI/MONAI/actions/runs/5209733342

tests/test_integration_workflows_gan.py
MONAI version: 0+untagged.1.gcc90d74
Numpy version: 1.22.3
Pytorch version: 2.0.1+cu117
MONAI flags: HAS_EXT = True, USE_COMPILED = True, USE_META_DICT = False
MONAI rev id: cc90d74b703a8f5494852577ee931c8c1aee0b1a
MONAI __file__: /__w/MONAI/MONAI/monai/__init__.py

Optional dependencies:
Pytorch Ignite version: 0.4.11
ITK version: 5.3.0
Nibabel version: 5.1.0
scikit-image version: 0.21.0
Pillow version: 9.0.1
Tensorboard version: 2.8.0
gdown version: 4.7.1
TorchVision version: 0.15.2+cu117
tqdm version: 4.64.0
lmdb version: 1.3.0
psutil version: 5.9.0
pandas version: 1.3.5
einops version: 0.6.1
transformers version: 4.21.3
mlflow version: 2.4.0
pynrrd version: 1.0.0

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies

monai.transforms.io.dictionary LoadImaged.__init__:image_only: Current default value of argument `image_only=False` has been deprecated since version 1.1. It will be changed to `image_only=True` in version 1.3.

Loading dataset:   0%|          | 0/20 [00:00<?, ?it/s]
Loading dataset: 100%|██████████| 20/20 [00:00<00:00, 350.91it/s]
Current run is terminating due to exception: Expected 3D (unbatched) or 4D (batched) input to conv2d, but got input of size: [2, 1, 64, 64, 1]
2023-06-08 11:43:36,468 - ERROR - Exception: Expected 3D (unbatched) or 4D (batched) input to conv2d, but got input of size: [2, 1, 64, 64, 1]
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/ignite/engine/engine.py", line 1068, in _run_once_on_dataset_as_gen
    self.state.output = self._process_function(self, self.state.batch)
  File "/__w/MONAI/MONAI/monai/engines/trainer.py", line 403, in _iteration
    dloss = engine.d_loss_function(g_output, d_input)
  File "/__w/MONAI/MONAI/tests/test_integration_workflows_gan.py", line 68, in discriminator_loss
    realloss = disc_loss_criterion(disc_net(real_images), real)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/__w/MONAI/MONAI/monai/networks/nets/regressor.py", line 150, in forward
    x = self.net(x)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/container.py", line 217, in forward
    input = module(input)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/__w/MONAI/MONAI/monai/networks/blocks/convolutions.py", line 316, in forward
    res: torch.Tensor = self.residual(x)  # create the additive residual from x
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 463, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
    return F.conv2d(input, weight, bias, self.stride,
  File "/__w/MONAI/MONAI/monai/data/meta_tensor.py", line 276, in __torch_function__
    ret = super().__torch_function__(func, types, args, kwargs)
  File "/opt/conda/lib/python3.8/site-packages/torch/_tensor.py", line 1295, in __torch_function__
    ret = func(*args, **kwargs)
RuntimeError: Expected 3D (unbatched) or 4D (batched) input to conv2d, but got input of size: [2, 1, 64, 64, 1]
Engine run is terminating due to exception: Expected 3D (unbatched) or 4D (batched) input to conv2d, but got input of size: [2, 1, 64, 64, 1]
2023-06-08 11:43:37,863 - ERROR - Exception: Expected 3D (unbatched) or 4D (batched) input to conv2d, but got input of size: [2, 1, 64, 64, 1]
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/ignite/engine/engine.py", line 959, in _internal_run_as_gen
    epoch_time_taken += yield from self._run_once_on_dataset_as_gen()
  File "/opt/conda/lib/python3.8/site-packages/ignite/engine/engine.py", line 1087, in _run_once_on_dataset_as_gen
    self._handle_exception(e)
  File "/opt/conda/lib/python3.8/site-packages/ignite/engine/engine.py", line 636, in _handle_exception
    self._fire_event(Events.EXCEPTION_RAISED, e)
  File "/opt/conda/lib/python3.8/site-packages/ignite/engine/engine.py", line 425, in _fire_event
    func(*first, *(event_args + others), **kwargs)
  File "/__w/MONAI/MONAI/monai/handlers/stats_handler.py", line 203, in exception_raised
    raise e
  File "/opt/conda/lib/python3.8/site-packages/ignite/engine/engine.py", line 1068, in _run_once_on_dataset_as_gen
    self.state.output = self._process_function(self, self.state.batch)
  File "/__w/MONAI/MONAI/monai/engines/trainer.py", line 403, in _iteration
    dloss = engine.d_loss_function(g_output, d_input)
  File "/__w/MONAI/MONAI/tests/test_integration_workflows_gan.py", line 68, in discriminator_loss
    realloss = disc_loss_criterion(disc_net(real_images), real)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/__w/MONAI/MONAI/monai/networks/nets/regressor.py", line 150, in forward
    x = self.net(x)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/container.py", line 217, in forward
    input = module(input)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/__w/MONAI/MONAI/monai/networks/blocks/convolutions.py", line 316, in forward
    res: torch.Tensor = self.residual(x)  # create the additive residual from x
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 463, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
    return F.conv2d(input, weight, bias, self.stride,
  File "/__w/MONAI/MONAI/monai/data/meta_tensor.py", line 276, in __torch_function__
    ret = super().__torch_function__(func, types, args, kwargs)
  File "/opt/conda/lib/python3.8/site-packages/torch/_tensor.py", line 1295, in __torch_function__
    ret = func(*args, **kwargs)
RuntimeError: Expected 3D (unbatched) or 4D (batched) input to conv2d, but got input of size: [2, 1, 64, 64, 1]

probably introduced by https://github.com/Project-MONAI/MONAI/commit/cc90d74b703a8f5494852577ee931c8c1aee0b1a @drbeh please check

wyli commented 1 year ago

I'm including this fix https://github.com/Project-MONAI/MONAI/pull/6593/commits/983b53f6adc1667c2525291ff59a20572e534c09