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] Testing for torch.cuda.is_available (the function not its return value) is always true #7

Closed tvercaut closed 2 years ago

tvercaut commented 2 years ago

Describe the bug Examples and notebooks make use of a construct along the lines of

device = "cuda" if torch.cuda.is_available else "cpu"

However torch.cuda.is_available is a function. One should thus test for the return value of the function rather than the function itsef. E.g.

device = "cuda" if torch.cuda.is_available() else "cpu"

To Reproduce Run an example notebok in colab with no GPU: https://colab.research.google.com/github/masadcv/FastGeodis/blob/master/samples/simpledemo2d.ipynb

Expected behavior The examples and notebooks should run on CPU as well.

masadcv commented 2 years ago

Many thanks for pointing this out. I am fixing this now!