ROCm / bitsandbytes

8-bit CUDA functions for PyTorch
MIT License
38 stars 4 forks source link

CMake Error when trying to build for specific gpu arch #44

Open mamei16 opened 2 months ago

mamei16 commented 2 months ago

System Info

OS: openSUSE Leap 15.6 ROCm version: 6.2.0 GPU: AMD Radeon RX 6800M CMake version: 3.28.3

Reproduction

git clone --recurse https://github.com/ROCm/bitsandbytes
cd bitsandbytes
git checkout rocm_enabled
pip install -r requirements-dev.txt
export CXX=/opt/rocm/llvm/bin/clang++
export CC=/opt/rocm/llvm/bin/clang
export Clang_DIR=/opt/rocm/llvm/lib/cmake/clang
export LLVM_DIR=/opt/rocm/llvm/lib/cmake/llvm
export AMDDeviceLibs_DIR=/opt/rocm-6.2.0/lib/cmake/AMDDeviceLibs/
export amd_comgr_DIR=/opt/rocm-6.2.0/lib/cmake/amd_comgr/
cmake -DCOMPUTE_BACKEND=hip -DAMDGPU_TARGETS=gfx1030 -S .

Expected behavior

No error should occur.

It seems simply moving the enable_language(HIP) line down to line 198 below the if statements fixes the issue.

mamei16 commented 2 months ago

Here is the full error output:

-- The CXX compiler identification is Clang 18.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/rocm/llvm/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring bitsandbytes (Backend: hip)
-- NO_CUBLASLT := OFF
-- The HIP compiler identification is Clang 18.0.0
-- Detecting HIP compiler ABI info
-- Detecting HIP compiler ABI info - failed
-- Check for working HIP compiler: /opt/rocm-6.2.0/lib/llvm/bin/clang++
-- Check for working HIP compiler: /opt/rocm-6.2.0/lib/llvm/bin/clang++ - broken
CMake Error at /usr/share/cmake/Modules/CMakeTestHIPCompiler.cmake:73 (message):
  The HIP compiler

    "/opt/rocm-6.2.0/lib/llvm/bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/home/user/Documents/python_files/bitsandbytes/CMakeFiles/CMakeScratch/TryCompile-aR1Qmi'

    Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_697f8/fast
    /usr/bin/gmake  -f CMakeFiles/cmTC_697f8.dir/build.make CMakeFiles/cmTC_697f8.dir/build
    gmake[1]: Entering directory '/home/user/Documents/python_files/bitsandbytes/CMakeFiles/CMakeScratch/TryCompile-aR1Qmi'
    Building HIP object CMakeFiles/cmTC_697f8.dir/testHIPCompiler.hip.o
    /opt/rocm-6.2.0/lib/llvm/bin/clang++  -D__HIP_ROCclr__=1 -isystem /opt/rocm-6.2.0/include --cuda-host-only  --offload-arch=gfx103a --offload-arch=gfx103a -o CMakeFiles/cmTC_697f8.dir/testHIPCompiler.hip.o -x hip -c /home/user/Documents/python_files/bitsandbytes/CMakeFiles/CMakeScratch/TryCompile-aR1Qmi/testHIPCompiler.hip
    clang++: error: invalid target ID 'gfx103a'; format is a processor name followed by an optional colon-delimited list of features followed by an enable/disable sign (e.g., 'gfx908:sramecc+:xnack-')
    clang++: error: invalid target ID 'gfx103a'; format is a processor name followed by an optional colon-delimited list of features followed by an enable/disable sign (e.g., 'gfx908:sramecc+:xnack-')
    gmake[1]: *** [CMakeFiles/cmTC_697f8.dir/build.make:78: CMakeFiles/cmTC_697f8.dir/testHIPCompiler.hip.o] Error 1
    gmake[1]: Leaving directory '/home/user/Documents/python_files/bitsandbytes/CMakeFiles/CMakeScratch/TryCompile-aR1Qmi'
    gmake: *** [Makefile:127: cmTC_697f8/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:175 (enable_language)

-- Configuring incomplete, errors occurred!
coconut009 commented 1 month ago

since you are using rocm-6.2 try the rocm-6.2 branch
i have a 7900xtx,m works fine on my end