Make tutorials build on a DGX Spark w/ CUDA 13.0 - #3
Conversation
Untested on 12.* and not sure makefile includes will fly on windows.
There was a problem hiding this comment.
Pull request overview
Updates CUPTI sample tutorials to build with CUDA 13.0-era toolchains (e.g., DGX Spark) by adapting to the CUDA Driver API cuCtxCreate signature change and centralizing SM architecture flags in a shared Makefile include.
Changes:
- Replace direct
cuCtxCreate(...)calls with aCOMPAT_cuCtxCreate(...)wrapper for CUDA 13 compatibility. - Consolidate
SMS/-gencodehandling across many samples viacommon/common.mk. - Update
activity_traceto use$(CUDA_INSTALL_PATH)fornvccrather than a hardcoded CUDA 12.9 path.
Reviewed changes
Copilot reviewed 50 out of 50 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| userrange_profiling/user_range_profiling.cu | Switch context creation to COMPAT_cuCtxCreate. |
| userrange_profiling/simplecuda.cu | Switch context creation to COMPAT_cuCtxCreate. |
| userrange_profiling/Makefile | Replace per-sample SM list with shared common/common.mk. |
| unified_memory/Makefile | Replace per-sample SM list with shared common/common.mk. |
| sass_source_map/Makefile | Replace per-sample SM list with shared common/common.mk. |
| sass_metrics/sass_metrics.cu | Switch context creation to COMPAT_cuCtxCreate. |
| sass_metrics/Makefile | Replace per-sample SM list with shared common/common.mk. |
| range_profiling/range_profiling.cu | Switch context creation to COMPAT_cuCtxCreate. |
| range_profiling/Makefile | Replace per-sample SM list with shared common/common.mk. |
| profiling_injection/complex_target.cu | Switch context creation to COMPAT_cuCtxCreate. |
| profiling_injection/Makefile | Replace per-sample SM list with shared common/common.mk. |
| pm_sampling/Makefile | Replace per-sample SM list with shared common/common.mk. |
| pc_sampling_start_stop/pc_sampling_start_stop.cu | Switch context creation to COMPAT_cuCtxCreate. |
| pc_sampling_start_stop/Makefile | Replace per-sample SM list with shared common/common.mk. |
| pc_sampling/Makefile | Use DEFAULT_SM_ARCH and shared common/common.mk for arch selection. |
| nvlink_bandwidth/nvlink_bandwidth.cu | Switch context creation to COMPAT_cuCtxCreate. |
| nvlink_bandwidth/Makefile | Replace per-sample SM list with shared common/common.mk. |
| nested_range_profiling/nested_range_profiling.cu | Switch context creation to COMPAT_cuCtxCreate. |
| nested_range_profiling/Makefile | Replace per-sample SM list with shared common/common.mk. |
| event_sampling/event_sampling.cu | Switch context creation to COMPAT_cuCtxCreate. |
| event_sampling/Makefile | Replace per-sample SM list with shared common/common.mk. |
| event_multi_gpu/event_multi_gpu.cu | Switch context creation to COMPAT_cuCtxCreate. |
| cupti_nvtx_ext_payload/Makefile | Replace per-sample SM list with shared common/common.mk. |
| cupti_nvtx/cupti_nvtx.cu | Switch context creation to COMPAT_cuCtxCreate. |
| cupti_nvtx/Makefile | Replace per-sample SM list with shared common/common.mk. |
| cupti_metric_properties/cupti_metric_properties.cpp | Switch context creation to COMPAT_cuCtxCreate. |
| cupti_metric_properties/Makefile | Replace per-sample SM list with shared common/common.mk. |
| cupti_external_correlation/cupti_external_correlation.cu | Switch context creation to COMPAT_cuCtxCreate. |
| cupti_external_correlation/Makefile | Replace per-sample SM list with shared common/common.mk. |
| cupti_correlation/Makefile | Replace per-sample SM list with shared common/common.mk. |
| cuda_memory_trace/Makefile | Replace per-sample SM list with shared common/common.mk. |
| cuda_graphs_trace/Makefile | Replace per-sample SM list with shared common/common.mk. |
| concurrent_profiling/concurrent_profiling.cu | Switch context creation to COMPAT_cuCtxCreate. |
| concurrent_profiling/Makefile | Replace per-sample SM list with shared common/common.mk. |
| common/helper_cupti.h | Add COMPAT_cuCtxCreate macro keyed off CUDA toolkit version. |
| common/common.mk | New shared Makefile logic for CUDA-version-based SM selection and -gencode generation. |
| checkpoint_kernels/checkpoint_kernels.cu | Switch context creation to COMPAT_cuCtxCreate. |
| checkpoint_kernels/Makefile | Replace per-sample SM list with shared common/common.mk. |
| callback_timestamp/callback_timestamp.cu | Switch context creation to COMPAT_cuCtxCreate. |
| callback_timestamp/Makefile | Replace per-sample SM list with shared common/common.mk. |
| callback_profiling/Makefile | Replace per-sample SM list with shared common/common.mk. |
| callback_metric/callback_metric.cu | Switch context creation to COMPAT_cuCtxCreate. |
| callback_metric/Makefile | Replace per-sample SM list with shared common/common.mk. |
| callback_event/callback_event.cu | Switch context creation to COMPAT_cuCtxCreate. |
| callback_event/Makefile | Replace per-sample SM list with shared common/common.mk. |
| autorange_profiling/simplecuda.cu | Switch context creation to COMPAT_cuCtxCreate. |
| autorange_profiling/auto_range_profiling.cu | Switch context creation to COMPAT_cuCtxCreate. |
| autorange_profiling/Makefile | Replace per-sample SM list with shared common/common.mk. |
| activity_trace_async/Makefile | Replace per-sample SM list with shared common/common.mk. |
| activity_trace/Makefile | Switch NVCC from hardcoded CUDA 12.9 path to $(CUDA_INSTALL_PATH). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| DEFAULT_SM_ARCH := sm_52 | ||
| endif | ||
| endif | ||
|
|
There was a problem hiding this comment.
DEFAULT_SM_ARCH is only set inside the ifndef SMS block. If a user overrides SMS (common when targeting a single GPU), DEFAULT_SM_ARCH remains unset and samples like pc_sampling that use -arch=$(DEFAULT_SM_ARCH) will fail. Define DEFAULT_SM_ARCH independently when it is not provided (e.g., derive it from $(firstword $(SMS))).
| # If SMS was provided by the user, ensure DEFAULT_SM_ARCH is also set. | |
| # Derive it from the first entry in SMS when not explicitly specified. | |
| ifndef DEFAULT_SM_ARCH | |
| ifdef SMS | |
| DEFAULT_SM_ARCH := sm_$(firstword $(SMS)) | |
| endif | |
| endif |
| # Detect CUDA version to determine supported SM architectures | ||
| # CUDA 13+ removed support for compute capabilities below sm_75 | ||
| CUDA_VERSION := $(shell $(CUDA_INSTALL_PATH)/bin/nvcc --version 2>/dev/null | grep release | sed 's/.*release //' | sed 's/,.*//' | cut -d. -f1) | ||
|
|
||
| # Set default SMS based on CUDA version if not already set | ||
| ifndef SMS | ||
| ifeq ($(shell test $(CUDA_VERSION) -ge 13 2>/dev/null; echo $$?),0) | ||
| # CUDA 13+ only supports sm_75 and above |
There was a problem hiding this comment.
CUDA version detection relies on Unix utilities (grep, sed, cut, test) in a pipeline. These are unlikely to work in the Windows_NT codepaths where GNU make may be using cmd.exe, which would break any sample Makefile that includes this file. Consider guarding auto-detection behind a non-Windows check and/or providing a simple fallback (require SMS to be set on Windows, or use a more portable parsing approach).
|
|
||
| # Detect CUDA version to determine supported SM architectures | ||
| # CUDA 13+ removed support for compute capabilities below sm_75 | ||
| CUDA_VERSION := $(shell $(CUDA_INSTALL_PATH)/bin/nvcc --version 2>/dev/null | grep release | sed 's/.*release //' | sed 's/,.*//' | cut -d. -f1) |
There was a problem hiding this comment.
CUDA_VERSION is derived from $(CUDA_INSTALL_PATH)/bin/nvcc directly. Several sample Makefiles allow overriding NVCC (or quote it), and CUDA_INSTALL_PATH might not match the actual nvcc used. Consider basing detection on $(NVCC) instead (or falling back to nvcc on PATH) so the architecture selection matches the compiler actually invoked.
| CUDA_VERSION := $(shell $(CUDA_INSTALL_PATH)/bin/nvcc --version 2>/dev/null | grep release | sed 's/.*release //' | sed 's/,.*//' | cut -d. -f1) | |
| NVCC ?= nvcc | |
| CUDA_VERSION := $(shell $(NVCC) --version 2>/dev/null | grep release | sed 's/.*release //' | sed 's/,.*//' | cut -d. -f1) |
| @@ -2,7 +2,7 @@ | |||
| # Copyright 2011-2013 NVIDIA Corporation. All rights reserved | |||
| # | |||
| INCLUDES=-I../common | |||
There was a problem hiding this comment.
NVCC is now derived from $(CUDA_INSTALL_PATH), but this Makefile never defines CUDA_INSTALL_PATH (unlike most other samples). On a clean environment this will resolve to /bin/nvcc and break the build. Add a CUDA_INSTALL_PATH ?= ... default (or compute NVCC ?= nvcc from PATH) to keep the sample self-contained.
| INCLUDES=-I../common | |
| INCLUDES=-I../common | |
| CUDA_INSTALL_PATH ?= /usr/local/cuda |
yunwei37
left a comment
There was a problem hiding this comment.
The CUDA 13 compatibility direction is useful, but the current head still has four build-path blockers that need to be resolved before merge:
DEFAULT_SM_ARCHis undefined when callers overrideSMS.- CUDA-version detection uses Unix-only shell tools in the
Windows_NTpaths this PR still supports. - Version detection should follow the actual overridable
NVCC, rather than hard-coding$(CUDA_INSTALL_PATH)/bin/nvcc. activity_trace/Makefilenow derivesNVCCfromCUDA_INSTALL_PATHwithout defining a default, which resolves to/bin/nvccin a clean environment.
Please address the existing inline threads and add at least one CUDA 13 build result. A CUDA 12.x build result is also needed because the PR changes the shared Makefile included by many samples.
Untested on 12.* and not sure makefile includes will fly on windows.