Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be two issues here.

  1. You discard both the standard output and the error output. So ifneq (,$(shell command -v nvidia-smi > /dev/null 2>&1)) is always false.

  2. It seems checking for nvidia-smi can also be unreliable. One can install nvidia-utils to get nvidia-smi (even on a machine that does not have an NVidia GPU) without installing cuda, etc. But we need nvcc to compile the code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You discard both the standard output and the error output. So ifneq (,$(shell command -v nvidia-smi > /dev/null 2>&1)) is always false.

Ack, you're right of course. That should have been only 2> /dev/null. And of course, I only bothered to test it on a system that didn't have nvidia-smi, so the resulting behavior was what I expected. Anyway, thank you very for catching that.

  1. It seems checking for nvidia-smi can also be unreliable. One can install nvidia-utils to get nvidia-smi (even on a machine that does not have an NVidia GPU) without installing cuda, etc. But we need nvcc to compile the code.

Darn it. I guess one would need to test for nvcc and nvidia-smi, then grep the output of running nvidia-smi for an indication of a gpu card. This is getting complicated :-(.

I'm doing to close this PR and issue #884 and try to reproduce whatever led me to think it was an issue in the first place.

# nvcc adds appropriate -I and -L flags, so nothing more is needed here.
TARGETS += qsim-cuda
TESTS += run-cuda-tests
Expand Down
4 changes: 2 additions & 2 deletions pybind_interface/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading