tatsy/torchmcubes

mcubes_pytorch fails on certain non-power of 2 resolution

aluo-x opened this issue · 4 comments

Thanks for this awesome project!

Not sure if this is intentional or a bug, but for CUDA tensors at least, this project fails for certain resolutions that are not power of 2.

So using the example provided, it will fail to give the correct verts & faces if the resolution is set to 96 or 101.

Tested on CUDA 11.1, Pytorch 1.7.1, 1080TI & Titan XP.

tatsy commented

Hi @aluo-x, thank you for your comment.

So, you mean that my program works in your env. with N=64, 128 (i.e., power of two size), but it does not work with N=96, 101 (i.e., NON power of two size), right?

Please let me to double check if the sizes N = 64, 128 do work in your environment.

Yes, the program works for N=64, 128, but fails when N=96, 101.
Oddly enough, it also works for certain non-power of 2 sizes, although I'm not seeing a pattern.

tatsy commented

it also works for certain non-power of 2 sizes, although I'm not seeing a pattern.

Humm, it's odd exactly. I will check it later. Thank you for your information.

tatsy commented

Hi @aluo-x, I have now fixed the bug for non-power-of-two-sized volumes. I've obtained the correct result for both or 96, 101, and others! (3186f25)

The problem was on the prefix scan algorithm, the following line was the problem:
https://github.com/tatsy/mcubes_pytorch/blob/5812e3c05ffde3a52890db79695381d921e51586/cxx/pscan.cu#L133
which was previously:
https://github.com/tatsy/mcubes_pytorch/blob/2e1708e3490ee9e0a24240d56c52ad8c95b2e426/cxx/pscan.cu#L129

Sorry for my carelessness, and I hope this fix works on your environment!