Skip to content

Make tutorials build on a DGX Spark w/ CUDA 13.0 - #3

Open
gnurizen wants to merge 1 commit into
eunomia-bpf:masterfrom
gnurizen:cuda_13
Open

Make tutorials build on a DGX Spark w/ CUDA 13.0#3
gnurizen wants to merge 1 commit into
eunomia-bpf:masterfrom
gnurizen:cuda_13

Conversation

@gnurizen

@gnurizen gnurizen commented Nov 20, 2025

Copy link
Copy Markdown

Untested on 12.* and not sure makefile includes will fly on windows.

Untested on 12.* and not sure makefile includes will fly on windows.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 a COMPAT_cuCtxCreate(...) wrapper for CUDA 13 compatibility.
  • Consolidate SMS/-gencode handling across many samples via common/common.mk.
  • Update activity_trace to use $(CUDA_INSTALL_PATH) for nvcc rather 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.

Comment thread common/common.mk
DEFAULT_SM_ARCH := sm_52
endif
endif

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

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))).

Suggested change
# 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

Copilot uses AI. Check for mistakes.
Comment thread common/common.mk
Comment on lines +4 to +11
# 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

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Comment thread common/common.mk

# 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)

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Comment thread activity_trace/Makefile
@@ -2,7 +2,7 @@
# Copyright 2011-2013 NVIDIA Corporation. All rights reserved
#
INCLUDES=-I../common

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
INCLUDES=-I../common
INCLUDES=-I../common
CUDA_INSTALL_PATH ?= /usr/local/cuda

Copilot uses AI. Check for mistakes.

@yunwei37 yunwei37 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The CUDA 13 compatibility direction is useful, but the current head still has four build-path blockers that need to be resolved before merge:

  1. DEFAULT_SM_ARCH is undefined when callers override SMS.
  2. CUDA-version detection uses Unix-only shell tools in the Windows_NT paths this PR still supports.
  3. Version detection should follow the actual overridable NVCC, rather than hard-coding $(CUDA_INSTALL_PATH)/bin/nvcc.
  4. activity_trace/Makefile now derives NVCC from CUDA_INSTALL_PATH without defining a default, which resolves to /bin/nvcc in 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.

@yunwei37 yunwei37 mentioned this pull request Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants