Skip to content

Commit

Permalink
GNU Make: try nvidia-smi for CUDA arch if deviceQuery fails (AMReX-Co…
Browse files Browse the repository at this point in the history
…des#3997)

I recently updated my local workstation, and found that CUDA compilation
wasn't working properly due to `CUDA_ARCH` not being detected properly.
It turns out the `deviceQuery` utility is no longer distributed with the
toolkit since CUDA 12 or so. `nvidia-smi` can get that info, so we can
fall back to that if deviceQuery isn't present.
  • Loading branch information
yut23 authored Jun 25, 2024
1 parent 259db7c commit 27b399a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Tools/GNUMake/sites/Make.unknown
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ ifeq ($(USE_CUDA),TRUE)
COMPILE_CUDA_PATH = $(CUDA_HOME)
SYSTEM_CUDA_PATH = $(CUDA_HOME)

cuda_device_query_result := $(shell $(CUDA_HOME)/extras/demo_suite/deviceQuery | grep "CUDA Capability")
ifneq ($(wildcard $(CUDA_HOME)/extras/demo_suite/deviceQuery),)
cuda_device_query_result := $(shell $(CUDA_HOME)/extras/demo_suite/deviceQuery | grep "CUDA Capability")
else
# try nvidia-smi, as deviceQuery is no longer distributed with CUDA 12 and up
cuda_device_query_result := $(shell nvidia-smi --query-gpu=compute_cap --format=csv,noheader)
endif
ifneq ($(cuda_device_query_result),)
TEMP_CUDA_ARCH = $(lastword $(cuda_device_query_result))
# CUDA_ARCH = $(subst .,,$(TEMP_CUDA_ARCH))
Expand Down

0 comments on commit 27b399a

Please sign in to comment.