Libtorch, Cannot find NVTX3, find old NVTX instead

Hey,

I am compiling (using CMake 3.28) a CPP solver that links to libtorch (2.5.1). However, there is a warning about NVTX3 as "-- Could NOT find nvtx3 (missing: nvtx3_dir) "

I find it comes from libtorch/share/cmake/Caffe2/public/cuda.cmake

find_path(nvtx3_dir NAMES nvtx3 PATHS "${PROJECT_SOURCE_DIR}/third_party/NVTX/c/include" NO_DEFAULT_PATH)
find_package_handle_standard_args(nvtx3 DEFAULT_MSG nvtx3_dir)
if(nvtx3_FOUND)
  add_library(torch::nvtx3 INTERFACE IMPORTED)
  target_include_directories(torch::nvtx3 INTERFACE "${nvtx3_dir}")
  target_compile_definitions(torch::nvtx3 INTERFACE TORCH_CUDA_USE_NVTX3)
else()
  message(WARNING "Cannot find NVTX3, find old NVTX instead")
  add_library(torch::nvtoolsext INTERFACE IMPORTED)
  set_property(TARGET torch::nvtoolsext PROPERTY INTERFACE_LINK_LIBRARIES CUDA::nvToolsExt)
endif()

I checked “{PROJECT_SOURCE_DIR}” variable, and it refers to my source codes directory (where .c files are located), and of course, there is no “third-party” folder.

Configuration:
libtorch version: stable 2.5.1
CUDA version: 12.4

Do you have ideas on how to address this warning and check where NVTX3 is in the computer? Thanks for your time.

Best, Weitao.

Hey guys,

I found a solution to this problem. You can download NVTX3 from GitHub - NVIDIA/NVTX: The NVIDIA® Tools Extension SDK (NVTX) is a C-based Application Programming Interface (API) for annotating events, code ranges, and resources in your applications.. Then, the directory pathway in libtorch/share/cmake/Caffe2/public/cuda.cmake should be adjusted correspondingly. Once you have the NVTX3, the warning will not appear.

Best, Weitao.