Skip to content

Commit 810719b

Browse files
pytorchmergebotdmenig
authored andcommitted
Revert "[Reland2] Update NVTX to NVTX3 (pytorch#109843)"
This reverts commit dcb4862. Reverted pytorch#109843 on behalf of https://github.com/atalman due to Diff broke internal builds and tests ([comment](pytorch#109843 (comment)))
1 parent ce2d45d commit 810719b

File tree

16 files changed

+56
-25
lines changed

16 files changed

+56
-25
lines changed

.ci/pytorch/win-test-helpers/build_pytorch.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ set CUDA_PATH_V%VERSION_SUFFIX%=%CUDA_PATH%
6666
set CUDNN_LIB_DIR=%CUDA_PATH%\lib\x64
6767
set CUDA_TOOLKIT_ROOT_DIR=%CUDA_PATH%
6868
set CUDNN_ROOT_DIR=%CUDA_PATH%
69+
set NVTOOLSEXT_PATH=C:\Program Files\NVIDIA Corporation\NvToolsExt
70+
set PATH=%CUDA_PATH%\bin;%CUDA_PATH%\libnvvp;%PATH%
71+
72+
set CUDNN_LIB_DIR=%CUDA_PATH%\lib\x64
73+
set CUDA_TOOLKIT_ROOT_DIR=%CUDA_PATH%
74+
set CUDNN_ROOT_DIR=%CUDA_PATH%
75+
set NVTOOLSEXT_PATH=C:\Program Files\NVIDIA Corporation\NvToolsExt
6976
set PATH=%CUDA_PATH%\bin;%CUDA_PATH%\libnvvp;%PATH%
7077

7178
:cuda_build_end

.ci/pytorch/win-test-helpers/setup_pytorch_env.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ set CUDA_PATH_V%VERSION_SUFFIX%=%CUDA_PATH%
4040
set CUDNN_LIB_DIR=%CUDA_PATH%\lib\x64
4141
set CUDA_TOOLKIT_ROOT_DIR=%CUDA_PATH%
4242
set CUDNN_ROOT_DIR=%CUDA_PATH%
43+
set NVTOOLSEXT_PATH=C:\Program Files\NVIDIA Corporation\NvToolsExt
4344
set PATH=%CUDA_PATH%\bin;%CUDA_PATH%\libnvvp;%PATH%
4445
set NUMBAPRO_CUDALIB=%CUDA_PATH%\bin
4546
set NUMBAPRO_LIBDEVICE=%CUDA_PATH%\nvvm\libdevice

.ci/pytorch/win-test-helpers/test_custom_backend.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ if ERRORLEVEL 1 exit /b 1
3131

3232
:: Run tests C++-side and load the exported script module.
3333
cd build
34-
set PATH=%TMP_DIR_WIN%\build\torch\lib;%PATH%
34+
set PATH=C:\Program Files\NVIDIA Corporation\NvToolsExt\bin\x64;%TMP_DIR_WIN%\build\torch\lib;%PATH%
3535
test_custom_backend.exe model.pt
3636
if ERRORLEVEL 1 exit /b 1

.ci/pytorch/win-test-helpers/test_custom_script_ops.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ if ERRORLEVEL 1 exit /b 1
3131

3232
:: Run tests C++-side and load the exported script module.
3333
cd build
34-
set PATH=%TMP_DIR_WIN%\build\torch\lib;%PATH%
34+
set PATH=C:\Program Files\NVIDIA Corporation\NvToolsExt\bin\x64;%TMP_DIR_WIN%\build\torch\lib;%PATH%
3535
test_custom_ops.exe model.pt
3636
if ERRORLEVEL 1 exit /b 1

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,3 @@
149149
[submodule "third_party/mimalloc"]
150150
path = third_party/mimalloc
151151
url = https://github.com/microsoft/mimalloc.git
152-
[submodule "third_party/NVTX"]
153-
path = third_party/NVTX
154-
url = https://github.com/NVIDIA/NVTX.git

caffe2/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,8 +1548,7 @@ if(USE_CUDA)
15481548
target_link_libraries(torch_cpu PRIVATE torch::cudart)
15491549
endif()
15501550
target_link_libraries(torch_cuda INTERFACE torch::cudart)
1551-
target_link_libraries(torch_cuda PUBLIC c10_cuda)
1552-
target_link_libraries(torch_cuda PRIVATE torch::nvtoolsext)
1551+
target_link_libraries(torch_cuda PUBLIC c10_cuda torch::nvtoolsext)
15531552

15541553
target_include_directories(
15551554
torch_cuda INTERFACE $<INSTALL_INTERFACE:include>)
@@ -1606,7 +1605,7 @@ if(BUILD_SHARED_LIBS)
16061605
# not find them, because they're usually in non-standard locations)
16071606
if(USE_CUDA)
16081607
target_link_libraries(torch_global_deps ${Caffe2_PUBLIC_CUDA_DEPENDENCY_LIBS})
1609-
target_link_libraries(torch_global_deps torch::cudart)
1608+
target_link_libraries(torch_global_deps torch::cudart torch::nvtoolsext)
16101609
endif()
16111610
if(USE_TBB)
16121611
target_link_libraries(torch_global_deps TBB::tbb)

caffe2/python/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
th_root = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'torch')
2727
th_dll_path = os.path.join(th_root, 'lib')
2828

29+
if not os.path.exists(os.path.join(th_dll_path, 'nvToolsExt64_1.dll')) and \
30+
not os.path.exists(os.path.join(py_dll_path, 'nvToolsExt64_1.dll')):
31+
nvtoolsext_dll_path = os.path.join(
32+
os.getenv('NVTOOLSEXT_PATH', 'C:\\Program Files\\NVIDIA Corporation\\NvToolsExt'), 'bin', 'x64')
33+
else:
34+
nvtoolsext_dll_path = ''
35+
2936
import importlib.util
3037
import glob
3138
spec = importlib.util.spec_from_file_location('torch_version', os.path.join(th_root, 'version.py'))
@@ -43,7 +50,7 @@
4350

4451
import ctypes
4552
kernel32 = ctypes.WinDLL('kernel32.dll', use_last_error=True)
46-
dll_paths = list(filter(os.path.exists, [th_dll_path, py_dll_path, cuda_path]))
53+
dll_paths = list(filter(os.path.exists, [th_dll_path, py_dll_path, nvtoolsext_dll_path, cuda_path]))
4754
with_load_library_flags = hasattr(kernel32, 'AddDllDirectory')
4855
prev_error_mode = kernel32.SetErrorMode(0x0001)
4956

cmake/TorchConfig.cmake.in

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,30 @@ endif()
129129

130130
if(@USE_CUDA@)
131131
if(MSVC)
132-
set(TORCH_CUDA_LIBRARIES ${CUDA_LIBRARIES})
132+
if(NOT NVTOOLEXT_HOME)
133+
set(NVTOOLEXT_HOME "C:/Program Files/NVIDIA Corporation/NvToolsExt")
134+
endif()
135+
if(DEFINED ENV{NVTOOLSEXT_PATH})
136+
set(NVTOOLEXT_HOME $ENV{NVTOOLSEXT_PATH})
137+
endif()
138+
set(TORCH_CUDA_LIBRARIES
139+
${NVTOOLEXT_HOME}/lib/x64/nvToolsExt64_1.lib
140+
${CUDA_LIBRARIES})
141+
list(APPEND TORCH_INCLUDE_DIRS ${NVTOOLEXT_HOME}/include)
133142
find_library(CAFFE2_NVRTC_LIBRARY caffe2_nvrtc PATHS "${TORCH_INSTALL_PREFIX}/lib")
134143
list(APPEND TORCH_CUDA_LIBRARIES ${CAFFE2_NVRTC_LIBRARY})
135144
elseif(APPLE)
136145
set(TORCH_CUDA_LIBRARIES
137146
${CUDA_TOOLKIT_ROOT_DIR}/lib/libcudart.dylib
138147
${CUDA_TOOLKIT_ROOT_DIR}/lib/libnvrtc.dylib
148+
${CUDA_TOOLKIT_ROOT_DIR}/lib/libnvToolsExt.dylib
139149
${CUDA_LIBRARIES})
140150
else()
151+
find_library(LIBNVTOOLSEXT libnvToolsExt.so PATHS ${CUDA_TOOLKIT_ROOT_DIR}/lib64/)
141152
set(TORCH_CUDA_LIBRARIES
142153
${CUDA_CUDA_LIB}
143154
${CUDA_NVRTC_LIB}
155+
${LIBNVTOOLSEXT}
144156
${CUDA_LIBRARIES})
145157
endif()
146158
if(@BUILD_SHARED_LIBS@)

cmake/public/cuda.cmake

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ if(NOT CMAKE_CUDA_COMPILER_VERSION VERSION_EQUAL CUDAToolkit_VERSION)
6666
"V${CUDAToolkit_VERSION} in '${CUDAToolkit_INCLUDE_DIRS}'")
6767
endif()
6868

69+
if(NOT TARGET CUDA::nvToolsExt)
70+
message(FATAL_ERROR "Failed to find nvToolsExt")
71+
endif()
72+
6973
message(STATUS "Caffe2: CUDA detected: " ${CUDA_VERSION})
7074
message(STATUS "Caffe2: CUDA nvcc is: " ${CUDA_NVCC_EXECUTABLE})
7175
message(STATUS "Caffe2: CUDA toolkit directory: " ${CUDA_TOOLKIT_ROOT_DIR})
@@ -210,15 +214,10 @@ else()
210214
endif()
211215

212216
# nvToolsExt
213-
find_path(nvtx3_dir NAMES nvtx3 PATHS "${CUDA_INCLUDE_DIRS}" "${PROJECT_SOURCE_DIR}/third_party/NVTX/c/include" NO_DEFAULT_PATH)
214-
find_package_handle_standard_args(nvtx3 DEFAULT_MSG nvtx3_dir)
215-
if(nvtx3_FOUND)
216-
add_library(torch::nvtoolsext INTERFACE IMPORTED)
217-
target_include_directories(torch::nvtoolsext INTERFACE "${nvtx3_dir}")
218-
else()
219-
message(WARNING "Cannot find NVTX3")
220-
endif()
221-
217+
add_library(torch::nvtoolsext INTERFACE IMPORTED)
218+
set_property(
219+
TARGET torch::nvtoolsext PROPERTY INTERFACE_LINK_LIBRARIES
220+
CUDA::nvToolsExt)
222221

223222
# cublas
224223
add_library(caffe2::cublas INTERFACE IMPORTED)

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@
189189
# NCCL_INCLUDE_DIR
190190
# specify where nccl is installed
191191
#
192+
# NVTOOLSEXT_PATH (Windows only)
193+
# specify where nvtoolsext is installed
192194
#
193195
# ACL_ROOT_DIR
194196
# specify where Compute Library is installed

0 commit comments

Comments
 (0)