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
91 stars 14 forks source link

[BUG] GPU support only for single GPU, and the GPU ID must be "cuda:0" #43

Closed Lilac-Lee closed 1 year ago

Lilac-Lee commented 1 year ago

Describe the bug When you have multiple GPUs, and you want to specify a GPU (other than "cuda:0") to use, it will generate error messages, such as "CUDA error: an illegal memory access was encountered", or "CUDA error: invalid device ordinal".

To Reproduce Steps to reproduce the behavior:

  1. Use a GPU other than the default "cuda:0". For example, generate your input on "cuda:1"
  2. Get your input to the FastGeodis function
  3. See the CUDA error

Expected behavior Users should be able to specify which GPU to use.

Desktop (please complete the following information):

Could you help us fix the issue? Thank you.

masadcv commented 1 year ago

Hi @Lilac-Lee ,

Many thanks for spotting this bug. I have a fix for this at: https://github.com/masadcv/FastGeodis/tree/fix-multiple-cuda which I am still testing.

Could you give it a try and report if any problem? After my tests pass and you check, I will then release this as a package.

Just in case you need help with running from branch here are instructions on how to do it:

  1. In your working directory, clone this github repo: git clone https://github.com/masadcv/FastGeodis
  2. Change directory to repo and change branch to branch with fix: cd FastGeodis; git checkout fix-multiple-cuda
  3. Uninstall any previous FastGeodis version and install the one with fix: `pip3 uninstall FastGeodis -y; python setup.py install'
  4. Run your code with error to verify if it works fine with the fix

Let me know if you have any further questions on this?

Lilac-Lee commented 1 year ago

Hi @masadcv

Thanks for the update. I think it's good to go now! The error no longer exists. Now I can switch to a different GPU. Thank you.

Xueqian

masadcv commented 1 year ago

Hi, Did you switch branch properly? Because the new version from fix branch should be 1.0.2.

You need to install from branch using instructions from above as these changes are not yet released to pypi, so installing with pip install FastGeodis will not yet apply bug fix.

Lilac-Lee commented 1 year ago

Hi, yes, everything is correct now! I have updated my comments before. Good to go! Thank you!

Xueqian

masadcv commented 1 year ago

Thanks for confirming. I am now releasing v1.0.2 with this fix on PyPI. Should be available to install through pip install FastGeodis in about an hour or so.

masadcv commented 1 year ago

These are now released. Marking this as solved.