Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions merlin/core/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
HAS_GPU = False
try:
from numba import cuda

try:
HAS_GPU = len(cuda.gpus.lst) > 0
except cuda.cudadrv.error.CudaSupportError:
pass
except ImportError:
cuda = None

HAS_GPU = False
try:
from dask.distributed.diagnostics import nvml

HAS_GPU = nvml.device_get_count() > 0
except ImportError:
# We can use `cuda` to set `HAS_GPU` now that we
# know `distributed` is not installed (otherwise
# the `nvml` import would have succeeded)
HAS_GPU = cuda is not None