Flux exports the function ‘gpu’ which wraps all arrays in CuArrays if cuda is available.
It has a (not exported iirc) function called has_cuda (or maybe has_gpu) which it uses to determine if cuda is available. It basically uses the method from this thread to do so Weak dependence on CUDA packages, 2019 version