masadcv / FastGeodis

Fast Implementation of Generalised Geodesic Distance Transform for CPU (OpenMP) and GPU (CUDA)
https://fastgeodis.readthedocs.io
BSD 3-Clause "New" or "Revised" License
90 stars 14 forks source link

[BUG] function only supports 2D spatial inputs, received 70283598 #60

Closed ramonemiliani93 closed 1 month ago

ramonemiliani93 commented 1 month ago

Hi 👋

First, I want to thank you for the amazing library 🙌. I'm encountering an issue while trying to run a simple example, and I would greatly appreciate any help or guidance you can provide.

Describe the bug There is an error on PyTorch==2.2.2 when running the signed_generalised_geodesic3d method.

To Reproduce Steps to reproduce the behavior:

  1. pyenv local 3.10
  2. python -m venv .venv
  3. source .venv/bin/activate
  4. pip install "torch==xxx" FastGeodis
  5. Run the following script:
    import torch, FastGeodis
    image = torch.ones((1, 1, 9, 9, 9))
    mask = torch.ones((1, 1, 9, 9, 9))
    mask[0, 0, 4, 4, 4] = 0
    FastGeodis.signed_generalised_geodesic3d(image, mask, [1.0, 1.0, 1.0], 1e10, 0.0, 4)

Expected behavior The method should compute the signed map and not raise ValueError: function only supports 2D spatial inputs, received <number>. From the torch versions I tried (all with python 3.10):

Desktop (please complete the following information):

masadcv commented 1 month ago

Hi @ramonemiliani93,

Thanks for reporting this. It is indeed a very odd behaviour. From the example and macOS, I can infer that this error is coming from CPU execution (i.e. both your tensors are on cpu device), is this correct?

Did you try the unsigned geodesic functions directly? It may help debug further if you try those as well because signed distance is calling those functions internally...

Also please indicate you gcc/g++ or related compiler version that you are using for installation

masadcv commented 1 month ago

Hi @ramonemiliani93

I have looked into this with the same OS, Python and Pytorch versions that you mentioned failing here. It seems like in your case there is some conflict between what is used for compiling the library (often referred to as build dependency) and what you have installed in the virtualenv. This is related to issue report here: https://github.com/masadcv/FastGeodis/issues/6#issuecomment-1166380502

Can you try the following:

pip install FastGeodis --no-build-isolation --no-cache-dir

This should resolve the issue you are seeing. Please do let me know if it doesnt.

ramonemiliani93 commented 1 month ago

Hi @masadcv! Thanks a lot! This has solved the issue 💪 Tried it with torch 2.2.2 and it works 🙌