Detect CUDA during cmake and use the python library in cpu mode

Hey there,

I wonder if it is possible to detect if CUDA is installed and turn pytorch into cpu mode if not (or not at the right version). At this time cmake run just fine with CUDA recent versions.

I use this lines in the CMakeLists.txt:
execute_process(
COMMAND bash -c “python3 -c ‘import torch;print(torch.utils.cmake_prefix_path, end = “”)’”
OUTPUT_VARIABLE libtorch_local_path
)

list(APPEND CMAKE_PREFIX_PATH “${libtorch_local_path}”)

What do you think?
Thanks in advance!