Skip to content

Instantly share code, notes, and snippets.

@SamuelMarks
Forked from rigtorp/rocm.md
Last active July 24, 2023 03:38
Show Gist options
  • Save SamuelMarks/2342bb814126b825e8b995446f9dc8e6 to your computer and use it in GitHub Desktop.
Save SamuelMarks/2342bb814126b825e8b995446f9dc8e6 to your computer and use it in GitHub Desktop.
How to build rocm 3.6.x beta from source

Install rocm-cmake

git clone --depth=1 https://github.com/RadeonOpenCompute/rocm-cmake.git && \
mkdir 'rocm-cmake/build' && pushd "$_" && \
cmake -DCMAKE_INSTALL_PREFIX='/opt/rocm' .. && \
cmake --build . && \
sudo cmake --install . && \
popd

Install ROCT-Thunk-Interface

git clone -b roc-3.6.x --depth=1 https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface.git && \
mkdir 'ROCT-Thunk-Interface/build' && pushd "$_" && \
cmake -DCMAKE_INSTALL_PREFIX='/opt/rocm' .. && \
cmake --build . && \
sudo cmake --install . && \
sudo cp -r '../include' '/opt/rocm/' && \
popd

Install ROCR-Runtime

git clone -b rocm-3.6.x --depth=1 https://github.com/RadeonOpenCompute/ROCR-Runtime.git && \
mkdir 'ROCR-Runtime/src/build' && pushd "$_" && \
cmake -DCMAKE_INSTALL_PREFIX='/opt/rocm' -DHSAKMT_INC_PATH='/opt/rocm/include' -DHSAKMT_LIB_PATH='/opt/rocm/lib64' .. && \
cmake --build . && \
sudo cmake --install . && \
popd

Install rocminfo

git clone --depth=1 https://github.com/RadeonOpenCompute/rocminfo.git && \
mkdir 'rocminfo/build' && pushd "$_" && \
cmake -DCMAKE_INSTALL_PREFIX='/opt/rocm' -DROCM_DIR='/opt/rocm' .. && \
cmake --build . && \
sudo cmake --install . && \
popd

Install ROCM LLVM / CLang

git clone -b amd-stg-open --depth=1 https://github.com/RadeonOpenCompute/llvm-project.git && \
mkdir 'llvm-project/build' && pushd "$_" && \
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 && \
cmake --build . && \
sudo cmake --install . && \
popd

Install ROCm-Device-Libs

git clone -b amd-stg-open --depth=1 http://github.com/RadeonOpenCompute/ROCm-Device-Libs.git && \
mkdir 'ROCm-Device-Libs/build' && pushd "$_" && \
export PATH='/opt/rocm/llvm/bin:'"$PATH" && \
cmake -DCMAKE_INSTALL_PREFIX='/opt/rocm' .. && \
cmake --build . && \
sudo cmake --install . && \
popd

Install ROCm-CompilerSupport

git clone -b amd-stg-open --depth=1 https://github.com/RadeonOpenCompute/ROCm-CompilerSupport && \
export PATH='/opt/rocm/llvm/bin:'"$PATH" && \
mkdir 'ROCm-CompilerSupport/lib/comgr/build' && pushd "$_" && \
cmake -DCMAKE_INSTALL_PREFIX='/opt/rocm' .. && \
cmake --build . && \
sudo cmake --install . && \
popd

Install ROCclr

git clone -b roc-3.6.x --depth=1 https://github.com/ROCm-Developer-Tools/ROCclr.git && \
git clone -b roc-3.6.x --depth=1 https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git && \
\
export ROCclr_DIR="$(readlink -f ROCclr)" && \
export OPENCL_DIR="$(readlink -f ROCm-OpenCL-Runtime)" && \
\
mkdir -p "$ROCclr_DIR"'/build' && pushd "$_" && \
cmake -DOPENCL_DIR="$OPENCL_DIR" -DCMAKE_INSTALL_PREFIX='/opt/rocm/rocclr' .. && \
cmake --build . --parallel $(nproc) && \
sudo cmake --install . && \
popd

Install HIP

git clone -b roc-3.6.x https://github.com/ROCm-Developer-Tools/HIP.git && \
mkdir 'HIP/build' && pushd "$_" && \
cmake -DCMAKE_BUILD_TYPE='Release' -DHIP_COMPILER='clang' -DHIP_PLATFORM='rocclr' -DCMAKE_PREFIX_PATH='/opt/rocm' -DCMAKE_INSTALL_PREFIX='/opt/rocm' .. && \
cmake --build . && \
sudo cmake --install . && \
popd

Build sample

pushd 'HIP/samples/0_Intro/square' && \
export HIP_PATH='/opt/rocm' && \
cmake --build . && \
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment