There is a simple solution to this, which has been adopted by many packages already:
- add CUDA.jl as a normal dependency
- do
using CUDAin your package - check at runtime if CUDA is functional or not (with
CUDA.functional()) and use the GPU in function of this.
The installation of CUDA.jl as well as using CUDA and compiling CUDA.jl code will work without error on a system without GPU. Only at runtime, trying to use the GPU for real, it would fail. But, this you will avoid by not doing so if CUDA.functional() returns false.
Example:
- here is how it is done in ImplicitGlobalGrid