Skip to content

fix: ambiguous min in nms_kernel function#9469

Open
ddelgadovargas-cyber wants to merge 1 commit intopytorch:mainfrom
ddelgadovargas-cyber:fix_ambiguous_min
Open

fix: ambiguous min in nms_kernel function#9469
ddelgadovargas-cyber wants to merge 1 commit intopytorch:mainfrom
ddelgadovargas-cyber:fix_ambiguous_min

Conversation

@ddelgadovargas-cyber
Copy link
Copy Markdown

@ddelgadovargas-cyber ddelgadovargas-cyber commented Apr 6, 2026

I got the following error when building nms_kernel.cu

third_party/py/torchvision/torchvision/csrc/ops/cuda/nms_kernel.cu:190:7: error: no matching function for call to 'min'
  190 |       min(col_blocks, threadsPerBlock),
      |       ^~~
third_party/crosstool/v18/stable/toolchain/lib/clang/google3-trunk/include/__clang_cuda_math.h:201:16: note: candidate function not viable: call to __device__ function from __host__ function
  201 | __DEVICE__ int min(int __a, int __b) { return __nv_min(__a, __b); }
      |                ^
blaze-out/k8-opt-cuda/bin/third_party/gpus/cuda/_virtual_includes/_stage/third_party/gpus/cuda/include/crt/math_functions.hpp:868:38: note: candidate function not viable: call to __device__ function from __host__ function
  868 | __MATH_FUNCTIONS_DECL__ unsigned int min(const unsigned int a, const unsigned int b)
      |                                      ^
blaze-out/k8-opt-cuda/bin/third_party/gpus/cuda/_virtual_includes/_stage/third_party/gpus/cuda/include/crt/math_functions.hpp:873:38: note: candidate function not viable: call to __device__ function from __host__ function
  873 | __MATH_FUNCTIONS_DECL__ unsigned int min(const int a, const unsigned int b)
      |                                      ^
blaze-out/k8-opt-cuda/bin/third_party/gpus/cuda/_virtual_includes/_stage/third_party/gpus/cuda/include/crt/math_functions.hpp:878:38: note: candidate function not viable: call to __device__ function from __host__ function
  878 | __MATH_FUNCTIONS_DECL__ unsigned int min(const unsigned int a, const int b)
      |                                      ^
note: remaining 12 candidates omitted; pass -fshow-overloads=all to show them

The nms_kernel function is a Host function and the code inside the triple-angle brackets is evaluated on the CPU before the kernel is actually launched on the GPU. So, this change tells the compiler to explicitly use std::min.

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Apr 6, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9469

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

❌ 9 New Failures, 1 Unrelated Failure

As of commit 33b3ffd with merge base 4e58149 (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

@meta-cla meta-cla bot added the cla signed label Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant