quinngroup / dr1dl-Dask

Dictionary Learning in Dask
0 stars 0 forks source link

Implement CuPy/Cuda #2

Closed crumleyc closed 4 years ago

crumleyc commented 4 years ago

How to make this function work with or without a GPU available. What is the best way? Checking if this https://github.com/anderskm/gputil will return anything (None type if no GPUs available) i.e.

GPUtil.showUtilization()

OR:

try: 
  import cupy
  make cupy array
else:
  Make dask array
magsol commented 4 years ago

By virtue of the __array_function protocol you shouldn't have to conditionally import anything; cupy will call the numpy function equivalents (and vice versa) depending on whether or not a GPU is present.