From 1b2d752bec078bc117ed72672825d0256c0e3443 Mon Sep 17 00:00:00 2001 From: Dae Woo Kim Date: Fri, 8 May 2026 13:56:57 -0500 Subject: [PATCH] Gracefully skip CUDA tests when CUDAdrv is unavailable CUDAdrv is a legacy package that may not be installed even when CUDA libraries are present on the system. Wrap the CUDA setup in a try/catch so the test suite falls back to CPU-only rather than erroring out. Co-Authored-By: Claude Sonnet 4.6 --- test/runtests.jl | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index d0dc25c..c213566 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,15 +4,23 @@ using ImageCore.OffsetArrays using CenterIndexedArrays, RegisterCore, RegisterMismatchCommon using Test, Libdl -havecuda = isdefined(Main, :use_cuda) ? Main.use_cuda : !isempty(find_library(["libcudart", "cudart"], ["/usr/local/cuda"])) -if havecuda - println("Running both CPU and CUDA versions") - using CUDAdrv - import RegisterMismatchCuda - RMlist = (RegisterMismatch, RegisterMismatchCuda) - devlist = devices() # dev->capability(dev)[1] >= 2, nmax=1) -else - RMlist = (RegisterMismatch,) +let + _want_cuda = isdefined(Main, :use_cuda) ? Main.use_cuda : !isempty(find_library(["libcudart", "cudart"], ["/usr/local/cuda"])) + _loaded = false + if _want_cuda + try + @eval using CUDAdrv + @eval import RegisterMismatchCuda + global devlist = @eval devices() + global RMlist = (RegisterMismatch, @eval(RegisterMismatchCuda)) + _loaded = true + println("Running both CPU and CUDA versions") + catch + end + end + if !_loaded + global RMlist = (RegisterMismatch,) + end end accuracy = 1e-5 # new isapprox accuracy = 1e-6