-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build and install ROCm via TheRock in AMD images (#7)
- Loading branch information
Showing
4 changed files
with
140 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
# Copyright 2024 The IREE Authors | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# Install the AMD GPU DRM libraries and Vulkan. | ||
# In order to use this in the container, you must pass /dev/dri and /dev/kfd in as: | ||
# docker run --device=/dev/kfd --device=/dev/dri <docker ID> | ||
|
||
set -euo pipefail | ||
|
||
AMDGPU_VERSION=$1 | ||
|
||
ARCH="$(uname -m)" | ||
if [[ "${ARCH}" == "x86_64" ]]; then | ||
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl libnuma-dev gnupg \ | ||
&& curl -sL https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - \ | ||
&& printf "deb [arch=amd64] https://repo.radeon.com/amdgpu/${AMDGPU_VERSION}/ubuntu focal main" | tee /etc/apt/sources.list.d/amdgpu.list \ | ||
&& apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
libdrm-amdgpu-dev \ | ||
libdrm-dev | ||
else | ||
echo "Installing ROCM for ${ARCH} is not supported yet." | ||
fi | ||
|
||
wget https://github.com/GPUOpen-Drivers/AMDVLK/releases/download/v-2023.Q3.1/amdvlk_2023.Q3.1_amd64.deb && \ | ||
dpkg -i amdvlk_2023.Q3.1_amd64.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
# Copyright 2024 The IREE Authors | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# Build and install the parts of ROCm that are required by IREE. | ||
|
||
set -euo pipefail | ||
|
||
THE_ROCK_GIT_REFSPEC=${THE_ROCK_GIT_REFSPEC:-rocm-6.1.0} | ||
THE_ROCK_ROCM_MANIFEST_URL=${THE_ROCK_ROCM_MANIFEST_URL:-https://github.com/ROCm/ROCm.git} | ||
THE_ROCK_ROCM_MANIFEST_BRANCH=${THE_ROCK_ROCM_MANIFEST_BRANCH:-refs/tags/rocm-6.1.0} | ||
|
||
ARCH="$(uname -m)" | ||
|
||
if [[ "${ARCH}" != "x86_64" ]]; then | ||
echo "Installing TheRock (ROCm) for ${ARCH} is not supported yet." | ||
exit 0 | ||
fi | ||
|
||
if [ ! -d TheRock ]; then | ||
git clone https://github.com/nod-ai/TheRock.git \ | ||
--branch $THE_ROCK_GIT_REFSPEC \ | ||
--depth 1 | ||
cd TheRock | ||
else | ||
cd TheRock | ||
git fetch --depth 1 origin $THE_ROCK_GIT_REFSPEC | ||
git checkout FETCH_HEAD | ||
fi | ||
|
||
apt update | ||
apt install -y \ | ||
repo git-lfs libnuma-dev ninja-build g++ pkg-config libdrm-dev \ | ||
libelf-dev xxd libgl1-mesa-dev | ||
python -m pip install CppHeaderParser | ||
|
||
# Make sure git does not report Committer identity unknown errors. | ||
# export GIT_COMMITTER_NAME="Noname" | ||
# export GIT_AUTHOR_NAME="$GIT_COMMITTER_NAME" | ||
# export GIT_COMMITTER_EMAIL="[email protected]" | ||
# export GIT_AUTHOR_EMAIL="$GIT_COMMITTER_EMAIL" | ||
# export GIT_TERMINAL_PROMPT=0 | ||
# The buggy repo tool does not respect the above commented vars, | ||
# so it asks us about our idenity. | ||
git config --global user.email "Noname" | ||
git config --global user.name "[email protected]" | ||
|
||
git config --global color.ui true | ||
export GIT_TERMINAL_PROMPT=0 | ||
|
||
python ./build_tools/fetch_sources.py \ | ||
--manifest-url $THE_ROCK_ROCM_MANIFEST_URL \ | ||
--manifest-branch $THE_ROCK_ROCM_MANIFEST_BRANCH | ||
|
||
# The build fails with clang-19. | ||
export CC=gcc | ||
export CXX=g++ | ||
|
||
cmake -B build \ | ||
-GNinja \ | ||
-DCMAKE_INSTALL_PREFIX=/usr/local \ | ||
. | ||
|
||
cmake --build build | ||
|
||
cmake --install build --component amdgpu-runtime | ||
cmake --install build --component amdgpu-runtime-dev | ||
cmake --install build --component amdgpu-compiler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters