diff --git a/Makefile b/Makefile index b4e16da0..17dc99e0 100644 --- a/Makefile +++ b/Makefile @@ -57,11 +57,14 @@ else endif # Determine whether we can include CUDA and cuStateVec support. We build for -# CUDA if (i) we find $NVCC or (ii) $CUDA_PATH is set. For cuStateVec, there's -# no way to find the cuQuantum libraries other than by being told, so we rely -# on the user or calling environment to set variable $CUQUANTUM_ROOT. - -ifneq (,$(shell which $(NVCC))) +# CUDA if (i) we find nvidia-smi or (ii) $CUDA_PATH is set. For cuStateVec, +# there's no way to find the cuQuantum libraries other than by being told, so +# we rely on the user or calling environment to set variable $CUQUANTUM_ROOT. +# (Testing for nvidia-smi is a more reliable way of checking that a system has +# an NVIDIA GPU. Checking for nvcc may only tell you if the system can compile +# CUDA code, not necessarily if it can run it.) + +ifneq (,$(shell command -v nvidia-smi > /dev/null 2>&1)) # nvcc adds appropriate -I and -L flags, so nothing more is needed here. TARGETS += qsim-cuda TESTS += run-cuda-tests diff --git a/pybind_interface/Makefile b/pybind_interface/Makefile index 9bcc54b6..fa6cdfb8 100644 --- a/pybind_interface/Makefile +++ b/pybind_interface/Makefile @@ -54,9 +54,9 @@ PYBINDFLAGS_CUSTATEVEC = $(CUSTATEVECFLAGS) $(PYBINDFLAGS_CUDA) PYBINDFLAGS_HIP = -std=c++17 -Wall -shared -fPIC $(PYBIND_INCLUDES) # Check for nvcc to decide compilation mode. -ifeq ($(shell which $(NVCC)),) +ifeq ($(shell command -v $(NVCC) > /dev/null 2>&1),) # Check for hipcc to decide compilation mode. -ifeq ($(shell which $(HIPCC)),) +ifeq ($(shell command -v $(HIPCC) > /dev/null 2>&1),) pybind: pybind-cpu decide-cpu else pybind: pybind-hip decide-hip