Skip to content

[video][cuda][beta] decoder nvtx annotations#1228

Open
vkhalidov wants to merge 4 commits intomainfrom
vkhalidov/nvtx_annotations
Open

[video][cuda][beta] decoder nvtx annotations#1228
vkhalidov wants to merge 4 commits intomainfrom
vkhalidov/nvtx_annotations

Conversation

@vkhalidov
Copy link
Contributor

Summary

Introduces USE_NVTX CMake flag, which, if enabled, defines USE_NVTX C++ preprocessor macro.
The USE_NVTX macro defined whether NVTX annotations shold be added to the cuda:beta interface of torchcodec. NVTX annotations facilitate reading and analyzing data collected by NSight profiler.

Profile With Annotations (this PR)

Command line:

nsys profile \
--trace=cuda,nvtx,nvvideo,osrt \
--cuda-memory-usage=true \
--capture-range=none \
--sample=none \
-o nsight_report \
python3 <script> <arg0> <arg1> ...

Profile (note NVTX annotations related to decoder instantiation and frames decoding):
Screenshot 2026-02-10 at 14 01 45

Profile Without Annotations (before)

Same command line, profile (no NVTX annotations):
Screenshot 2026-02-10 at 14 04 38

Note: used NSight 2026.1.1 to visualize both profiles

Test Plan

  1. Tested torchcodec build with NVTX annotations enabled via an environment variable:
USE_NVTX=1 ENABLE_CUDA=1 pip install -e . --no-build-isolation -vv

and verified CMake cache entry:

//Enable NVTX annotations for profiling (requires CUDA)
USE_NVTX:BOOL=ON

Used this build to produce profile with NVTX annotations.

  1. Tested torchcodec build with NVTX annotations enabled via an environment variable, but disabled by CMake when ENABLE_CUDA is not set:
USE_NVTX=1 pip install -e . --no-build-isolation -vv

Observed the following message on build:

  CMake Warning at src/torchcodec/_core/CMakeLists.txt:17 (message): 
  USE_NVTX requires ENABLE_CUDA=ON.  Disabling USE_NVTX.

and the following entry in CMakeCache.txt:

//Enable NVTX annotations for profiling (requires CUDA)
USE_NVTX:BOOL=OFF
  1. Tested torchcodec build with NVTX annotations not enabled explicitly, with ENABLE_CUDA=1:
ENABLE_CUDA=1 pip install -e . --no-build-isolation -vv

and verified the CMake cache entry:

//Enable NVTX annotations for profiling (requires CUDA)
USE_NVTX:BOOL=OFF
  1. Tested torchcodec build without any environment variables:
pip install -e . --no-build-isolation -vv

and verified the CMake cache entry:

//Enable NVTX annotations for profiling (requires CUDA)
USE_NVTX:BOOL=OFF

@pytorch-bot
Copy link

pytorch-bot bot commented Feb 10, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1228

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 3693a8f with merge base 5800d58 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 10, 2026
@vkhalidov vkhalidov marked this pull request as ready for review February 10, 2026 13:18
@vkhalidov vkhalidov force-pushed the vkhalidov/nvtx_annotations branch from f7098c4 to fcf9335 Compare February 10, 2026 15:59
Base automatically changed from vkhalidov/decoder_caps_cache to main February 10, 2026 20:04
@vkhalidov vkhalidov force-pushed the vkhalidov/nvtx_annotations branch from bad8aa0 to c5659f5 Compare February 11, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants