From 08f125bcacd6537a0a4163ee665f4be74d65a67d Mon Sep 17 00:00:00 2001 From: Pruthvi Madugundu Date: Tue, 28 Mar 2023 19:28:38 +0000 Subject: [PATCH] [ROCm] Remove usage of deprecated ROCm component header includes (#97620) - clang parameter 'amdgpu-target' changed to 'offload-arch' - HIP and MIOpen includes path updated for extensions Pull Request resolved: https://github.com/pytorch/pytorch/pull/97620 Approved by: https://github.com/ezyang, https://github.com/jithunnair-amd --- cmake/Dependencies.cmake | 2 +- cmake/public/LoadHIP.cmake | 1 - torch/CMakeLists.txt | 1 - torch/utils/cpp_extension.py | 9 ++------- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index f62f3986283..015038e2fe4 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -1288,7 +1288,7 @@ if(USE_ROCM) # host linker to link. list(APPEND HIP_CLANG_FLAGS -fno-gpu-rdc) foreach(pytorch_rocm_arch ${PYTORCH_ROCM_ARCH}) - list(APPEND HIP_CLANG_FLAGS --amdgpu-target=${pytorch_rocm_arch}) + list(APPEND HIP_CLANG_FLAGS --offload-arch=${pytorch_rocm_arch}) endforeach() set(Caffe2_HIP_INCLUDE diff --git a/cmake/public/LoadHIP.cmake b/cmake/public/LoadHIP.cmake index b51284115f1..ba3959297c9 100644 --- a/cmake/public/LoadHIP.cmake +++ b/cmake/public/LoadHIP.cmake @@ -313,5 +313,4 @@ if(HIP_FOUND) find_library(ROCM_HIPRTC_LIB ${hip_library_name} HINTS ${HIP_PATH}/lib) # roctx is part of roctracer find_library(ROCM_ROCTX_LIB roctx64 HINTS ${ROCTRACER_PATH}/lib) - set(roctracer_INCLUDE_DIRS ${ROCTRACER_PATH}/include) endif() diff --git a/torch/CMakeLists.txt b/torch/CMakeLists.txt index 280d7a14c9d..f1a1fec8154 100644 --- a/torch/CMakeLists.txt +++ b/torch/CMakeLists.txt @@ -139,7 +139,6 @@ if(USE_ROCM) __HIP_PLATFORM_HCC__ ) list(APPEND TORCH_PYTHON_LINK_LIBRARIES ${ROCM_ROCTX_LIB}) - list(APPEND TORCH_PYTHON_INCLUDE_DIRECTORIES ${roctracer_INCLUDE_DIRS}) endif() if(USE_EXPERIMENTAL_CUDNN_V8_API) diff --git a/torch/utils/cpp_extension.py b/torch/utils/cpp_extension.py index b236ef606e6..91b27b9018a 100644 --- a/torch/utils/cpp_extension.py +++ b/torch/utils/cpp_extension.py @@ -200,7 +200,6 @@ CUDA was not found on the system, please set the CUDA_HOME or the CUDA_PATH environment variable or add NVCC to your system PATH. The extension compilation will fail. ''' ROCM_HOME = _find_rocm_home() -MIOPEN_HOME = _join_rocm_home('miopen') if ROCM_HOME else None HIP_HOME = _join_rocm_home('hip') if ROCM_HOME else None IS_HIP_EXTENSION = True if ((ROCM_HOME is not None) and (torch.version.hip is not None)) else False ROCM_VERSION = None @@ -1142,10 +1141,6 @@ def include_paths(cuda: bool = False) -> List[str]: if cuda and IS_HIP_EXTENSION: paths.append(os.path.join(lib_include, 'THH')) paths.append(_join_rocm_home('include')) - if MIOPEN_HOME is not None: - paths.append(os.path.join(MIOPEN_HOME, 'include')) - if HIP_HOME is not None: - paths.append(os.path.join(HIP_HOME, 'include')) elif cuda: cuda_home_include = _join_cuda_home('include') # if we have the Debian/Ubuntu packages for cuda, we get /usr as cuda home. @@ -1804,7 +1799,7 @@ def _get_rocm_arch_flags(cflags: Optional[List[str]] = None) -> List[str]: # (from `extra_compile_args`) if cflags is not None: for flag in cflags: - if 'amdgpu-target' in flag: + if 'amdgpu-target' in flag or 'offload-arch' in flag: return ['-fno-gpu-rdc'] # Use same defaults as used for building PyTorch # Allow env var to override, just like during initial cmake build. @@ -1817,7 +1812,7 @@ def _get_rocm_arch_flags(cflags: Optional[List[str]] = None) -> List[str]: archs = [] else: archs = _archs.replace(' ', ';').split(';') - flags = ['--amdgpu-target=%s' % arch for arch in archs] + flags = ['--offload-arch=%s' % arch for arch in archs] flags += ['-fno-gpu-rdc'] return flags