ROCm / hipamd

35 stars 37 forks source link

HIP build is fundamentally broken in 4.5 #16

Open gggh000 opened 2 years ago

gggh000 commented 2 years ago

It appears the instruction in INSTALL.md misled in such a way build expects the hipconfig in wrong place.

DCMAKE_INSTALL_PREFIX=$PWD/install .. -- HIP_COMMON_DIR found at /root/ROCm-4.5/hipamd/hip Can't open perl script "/root/ROCm-4.5/hipamd/hip/bin/hipconfig": No such file or directory

root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd/build# find ~/ROCm-4.5/ -name hipconfig /root/ROCm-4.5/HIP/bin/hipconfig

root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd# export HIPAMD_DIR="$(readlink -f hipamd)"
root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd# export HIP_DIR="$(readlink -f hip)"
root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd# export ROCclr_DIR="$(readlink -f ROCclr)"
root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd# export OPENCL_DIR="$(readlink -f ROCm-OpenCL-Runtime)"
root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd# 
root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd# mkdir -p build; cd build
root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd/build# 
root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd/build# cmake -DHIP_COMMON_DIR=$HIP_DIR -DAMD_OPENCL_PATH=$OPENCL_DIR -DROCCLR_PATH=$ROCCLR_DIR -DCMAKE_PREFIX_PATH="/opt/rocm/" -DCMAKE_INSTALL_PREFIX=$PWD/install ..
-- HIP_COMMON_DIR found at /root/ROCm-4.5/hipamd/hip
Can't open perl script "/root/ROCm-4.5/hipamd/hip/bin/hipconfig": No such file or directory
CMake Error at CMakeLists.txt:82 (string):
  string sub-command REPLACE requires at least four arguments.

-- Using CPACK_DEBIAN_PACKAGE_RELEASE local
-- CPACK_RPM_PACKAGE_RELEASE: local
-- HIP Platform: 
CMake Error at CMakeLists.txt:218 (message):
  Unexpected HIP_PLATFORM:

-- Configuring incomplete, errors occurred!
See also "/root/ROCm-4.5/hipamd/CMakeFiles/CMakeOutput.log".
root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd/build# nano -w ../../build-rocm.sh 
root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd/build#     echo HIPAMD_DIR: $HIPAMD_DIR, HIP_DIR: $HIP_DIR, ROCclr_DIR: $ROCclr_DIR, OPENCL_DIR: $OPENCL_DIR
HIPAMD_DIR: /root/ROCm-4.5/hipamd/hipamd, HIP_DIR: /root/ROCm-4.5/hipamd/hip, ROCclr_DIR: /root/ROCm-4.5/hipamd/ROCclr, OPENCL_DIR: /root/ROCm-4.5/hipamd/ROCm-OpenCL-Runtime
root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd/build# 
root@nonroot-SYS-7049GP-TRT:~/ROCm-4.5/hipamd/build# 
cgmb commented 2 years ago

You might find this script useful. Not everything in it will install to the right directory with DCMAKE_INSTALL_PREFIX specified, but it builds most of the components in ROCm 4.5 from source.

(That doesn't fix the issue if the INSTALL.md instructions are wrong, but I hope you at least find it useful as an additional reference.)

gggh000 commented 2 years ago

hi i looked at it however not sure if this resolves the fundamental build problem. INSTALL.md refers to instruction for HIP build. However i found that cmake command mistakes the case sensitives. It expects hipconfig in /hip but when downloaded through repo sync it created under /HIP. Once I create symlink hip that points to HIP, build appears to move on. This should be fixed I think.

gggh000 commented 2 years ago

There is another path issue that readlinks must be read from otherwise result in path error.

Mystro256 commented 2 years ago

If it helps, to get HIP building on Fedora I needed to do:

export HIP_CLANG_PATH=/usr/bin mkdir build cd build cmake -S.. -B. \ -DHIP_COMMON_DIR=/path/to/hip \ -DAMD_OPENCL_PATH=/path/to/ocl \ -DROCCLR_PATH=/path/to/rocclr \ -DHIP_COMPILER=clang make

But I only tried 5.0 and 5.1, not 4.5. Note that I did notice that HIP seems to assume cmake is run within the build directory, not the source directory, so you must use something like "cmake -S.. -B." (I not sure if that's the same as what you did). As well, exporting HIP_CLANG_PATH is needed to find clang, as it doesn't appear to fall back to PATH to find it.