Skip to content

Commit

Permalink
skip CUDA test if nvidia-smi not found
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisThielemans committed Jul 8, 2024
1 parent 3e43ca7 commit 66c082b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ if(NOT DISABLE_STIR_CUDA)
message(STATUS "STIR CUDA support enabled. Using CUDA version ${CUDAToolkit_VERSION}.")
set(STIR_WITH_CUDA ON)
endif()
# check if run-time is available for ctests
find_program(NVIDIA_SMI nvidia-smi)
if (NOT NVIDIA_SMI)
message(WARNING "nvidia-smi not found. Disabling the ctests using CUDA")
set(SKIP_CUDA_TESTS ON)
endif()
else()
message(WARNING "No CUDA compiler found. Setting DISABLE_STIR_CUDA to ON.")
set(DISABLE_STIR_CUDA ON)
Expand Down
7 changes: 6 additions & 1 deletion src/recon_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ set(${dir_SIMPLE_TEST_EXE_SOURCES}
test_DataSymmetriesForBins_PET_CartesianGrid.cxx
test_FBP2D.cxx
test_FBP3DRP.cxx
test_priors.cxx
test_blocks_on_cylindrical_projectors.cxx
test_geometry_blocks_on_cylindrical.cxx
)
Expand All @@ -37,6 +36,7 @@ set(${dir_INVOLVED_TEST_EXE_SOURCES}
test_data_processor_projectors.cxx
test_OSMAPOSL.cxx
test_PoissonLogLikelihoodWithLinearModelForMeanAndListModeWithProjMatrixByBin.cxx
test_priors.cxx
)

if (DOWNLOAD_ZENODO_TEST_DATA)
Expand Down Expand Up @@ -149,3 +149,8 @@ if (parallelproj_FOUND)
ADD_TEST(test_OSMAPOSL_parallelproj test_OSMAPOSL ${CMAKE_SOURCE_DIR}/examples/samples/projector_pair_parallelproj.par)
endif()

if (SKIP_CUDA_TESTS)
set (CUDA_TEST_ARG "--skip-cuda")
endif()

ADD_TEST(test_priors test_priors ${CUDA_TEST_ARG})
2 changes: 1 addition & 1 deletion src/recon_test/test_priors.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
\par Usage
<pre>
test_priors [ density_filename ]
test_priors [--skip-cuda] [ density_filename ]
</pre>
where the argument is optional. See the class documentation for more info.
Expand Down

0 comments on commit 66c082b

Please sign in to comment.