Skip to content

Instantly share code, notes, and snippets.

@rigtorp
Last active September 18, 2023 01:23
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rigtorp/d9483af100fb77cee57e4c9fa3c74245 to your computer and use it in GitHub Desktop.
Save rigtorp/d9483af100fb77cee57e4c9fa3c74245 to your computer and use it in GitHub Desktop.
How to build rocm 3.6.x beta from source

Install rocm-cmake

git clone https://github.com/RadeonOpenCompute/rocm-cmake.git
mkdir bulid
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm ..
make
sudo make install

Install ROCT-Thunk-Interface

git clone -b roc-3.6.x https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface.git
cd ROCT-Thunk-Interface
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm ..
make
sudo make install
sudo cp -r include /opt/rocm/

Install ROCR-Runtime

git clone -b rocm-3.6.x https://github.com/RadeonOpenCompute/ROCR-Runtime.git
cd ROCR-Runtime/src
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm -DHSAKMT_INC_PATH=/opt/rocm/include -DHSAKMT_LIB_PATH=/opt/rocm/lib64 ..
make
sudo make install

Install rocminfo

git clone https://github.com/RadeonOpenCompute/rocminfo.git
cd rocminfo
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm -DROCM_DIR=/opt/rocm ..
make
sudo make install

Install ROCM LLVM / CLang

git clone -b amd-stg-open https://github.com/RadeonOpenCompute/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/rocm/llvm -DLLVM_ENABLE_ASSERTIONS=1 -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" -DLLVM_ENABLE_PROJECTS="compiler-rt;lld;clang" ../llvm
make
sudo make install

Install ROCm-Device-Libs

git clone -b amd-stg-open http://github.com/RadeonOpenCompute/ROCm-Device-Libs.git
cd ROCm-Device-Libs
export PATH=/opt/rocm/llvm/bin:$PATH
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm ..
make
sudo make install

Install ROCm-CompilerSupport

git clone -b amd-stg-open https://github.com/RadeonOpenCompute/ROCm-CompilerSupport
cd ROCm-CompilerSupport/lib/comgr
export PATH=/opt/rocm/llvm/bin:$PATH
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm ..
make
sudo make install

Install ROCclr

git clone -b roc-3.6.x https://github.com/ROCm-Developer-Tools/ROCclr.git
git clone -b roc-3.6.x https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git

export ROCclr_DIR="$(readlink -f ROCclr)"
export OPENCL_DIR="$(readlink -f ROCm-OpenCL-Runtime)"

cd "$ROCclr_DIR"
mkdir -p build; cd build
cmake -DOPENCL_DIR="$OPENCL_DIR" -DCMAKE_INSTALL_PREFIX=/opt/rocm/rocclr ..
make -j$(nproc)
sudo make install

Install HIP

git clone -b roc-3.6.x https://github.com/ROCm-Developer-Tools/HIP.git
cd HIP
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DHIP_COMPILER=clang -DHIP_PLATFORM=rocclr -DCMAKE_PREFIX_PATH=/opt/rocm -DCMAKE_INSTALL_PREFIX=/opt/rocm ..
make
sudo make install

Build sample

cd HIP/samples/0_Intro/square
export HIP_PATH=/opt/rocm
make
@SamuelMarks
Copy link

SamuelMarks commented Jul 23, 2023

@rigtorp I've forked your variant to add:

  • syntax highlighting
  • reduce number of steps and simplify workflow through use of pushd & popd
  • change all clones to --depth=1
  • use cmake --build . instead of make and sudo cmake --install . instead of sudo make install

Would be great if you brought my changes in: https://gist.github.com/SamuelMarks/2342bb814126b825e8b995446f9dc8e6

EDIT: Ok so some issues, seems like:

[100%] Linking CXX shared library libhsa-runtime64.so
/usr/bin/ld: cannot find -lhsakmt: No such file or directory
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/hsa-runtime64.dir/build.make:674: libhsa-runtime64.so.1.1.9] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:89: CMakeFiles/hsa-runtime64.dir/all] Error 2
gmake: *** [Makefile:156: all] Error 2
-- Install configuration: ""
CMake Error at cmake_install.cmake:57 (file):
  file INSTALL cannot find
  "ROCm/ROCR-Runtime/src/build/libhsa-runtime64.so.1.1.9": No
  such file or directory.

@rigtorp
Copy link
Author

rigtorp commented Sep 18, 2023 via email

@SamuelMarks
Copy link

@rigtorp I don't blame you

@rigtorp
Copy link
Author

rigtorp commented Sep 18, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment