Skip to content

[ROCm] find_package(Torch) replaces an already-enabled CMAKE_HIP_COMPILER, so CMake deletes the project's cache #201447

Closed

Description

@0xDELUXA

🐛 Describe the bug

Since #180485, cmake/public/LoadHIP.cmake unconditionally sets CMAKE_HIP_COMPILER to ${ROCM_PATH}/lib/llvm/bin/clang++ before enable_language(HIP). If the project calling find_package(Torch) has already enabled HIP with a compiler path that is spelled differently, CMake treats it as a compiler change, deletes the whole cache and reconfigures without the user's -D options.

Minimal repro on Windows, CMakeLists.txt:

cmake_minimum_required(VERSION 3.21)
project(t CXX C)
set(CMAKE_HIP_COMPILER_FORCED TRUE)
enable_language(HIP)
find_package(Torch REQUIRED)
message(STATUS "MY_OPTION=${MY_OPTION}")
add_executable(m main.cpp)
target_link_libraries(m PRIVATE torch)

Configured with clang-cl for C/CXX, -DMY_OPTION=ON, CMAKE_PREFIX_PATH pointing at torch/share/cmake, and -DCMAKE_HIP_COMPILER set to the SDK's clang++.exe with a lowercase drive and directory names (the same file LoadHIP.cmake picks), the output is:

You have changed variables that require your cache to be deleted.

The configure then re-runs with MY_OPTION empty and CMAKE_PREFIX_PATH gone, and fails at find_package(Torch). With the identical path string it configures fine. In a real project this silently dropped the option that selected the HIP build, and the reconfigure took the project's other build path. Tested on Windows only; the same comparison applies on any platform where the project's HIP compiler path differs from the one LoadHIP.cmake computes.

Versions

PyTorch version: 2.16.0a0+rocm10.2.0a20261018
Is debug build: False
CUDA used to build PyTorch: N/A
ROCm SDK used to build PyTorch: 10.2.0
HIP used to build PyTorch: 7.17.26413

OS: Microsoft Windows 11 Pro (10.0.26300 64-bit)
GCC version: (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r8) 13.2.0
Clang version: 21.1.6
CMake version: version 4.0.2
Libc version: N/A

Python version: 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-11-10.0.26300-SP0
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to:
GPU models and configuration: AMD Radeon RX 9060 XT (gfx1200)
Nvidia driver version: Could not collect
cuDNN version: Could not collect
Is XPU available: False
HIP runtime version: 7.17.26413
MIOpen runtime version: 3.6.2
Is XNNPACK available: False
Caching allocator config: N/A

CPU:
Name: Intel(R) Core(TM) i5-14400F
Manufacturer: GenuineIntel
Family: 205
Architecture: 9
ProcessorType: 3
DeviceID: CPU0
CurrentClockSpeed: 2500
MaxClockSpeed: 2500
L2CacheSize: 9728
L2CacheSpeed: None
Revision: None

Versions of relevant libraries:
[pip3] amd-torch-device-gfx12-0==2.16.0a0+rocm10.2.0a20261018
[pip3] amd-torch-device-gfx1200==2.16.0a0+rocm10.2.0a20261018
[pip3] amd-torchvision-device-gfx1200==0.30.0a0+rocm10.2.0a20261018
[pip3] mypy_extensions==1.1.0
[pip3] numpy==2.3.2
[pip3] onnx==1.20.0
[pip3] onnxruntime==1.27.0
[pip3] onnxruntime-gpu==1.27.0
[pip3] open_clip_torch==3.2.0
[pip3] pytorch-lightning==2.6.5
[pip3] pytorch-metric-learning==2.9.0
[pip3] pytorch-ranger==0.1.1
[pip3] rotary-embedding-torch==0.8.3
[pip3] sageattention==2.2.0+rocm7.13torch2.10.0andhigher
[pip3] torch==2.16.0a0+rocm10.2.0a20261018
[pip3] torch-audiomentations==0.12.0
[pip3] torch-optimizer==0.1.0
[pip3] torch_pitch_shift==1.2.5
[pip3] torch-stoi==0.2.3
[pip3] torchaudio==2.11.1+rocm10.2.0a20261018
[pip3] torchcodec==0.14.0
[pip3] torchinfo==1.8.0
[pip3] torchmetrics==1.9.0
[pip3] torchsde==0.2.6
[pip3] torchvision==0.30.0a0+rocm10.2.0a20261018
[pip3] triton-windows==3.8.0.post28
[pip3] tritonblas==0.1.0
[conda] Could not collect

cc @malfet @zklaus @peterjc123 @mszhanyi @skyline75489 @nbcsm @iremyux @Blackhex @nkhasbag-nv @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

Activity

  1. added
    module: rocm
    on Oct 19, 2026
  2. added
    module: build
    module: windows
    triaged
    module: regression
    bot-triaged
    on Oct 19, 2026
  3. added a commit that references this issue on Oct 31, 2026
    dc674ee
  4. added 2 commits that reference this issue on Nov 5, 2026
    3054a33
    e2aea58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionablebot-triagedmodule: buildmodule: regressionmodule: rocmmodule: windowstriaged

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions