Skip to content

Commit 95fd656

Browse files
authored
Merge pull request #2 from kprinssu/feature/older-gfx-arch-v2
Fix CI for building older GFX Arches
2 parents 510714d + 3c3b3fb commit 95fd656

File tree

3 files changed

+129
-1
lines changed

3 files changed

+129
-1
lines changed

docker/rocm/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rocm/dev-ubuntu-24.04:6.4.3-complete
1+
FROM rocm/dev-ubuntu-24.04:6.4.4
22
ENV DEBIAN_FRONTEND=noninteractive \
33
PHONEMIZER_ESPEAK_PATH=/usr/bin \
44
PHONEMIZER_ESPEAK_DATA=/usr/share/espeak-ng-data \

docker/rocm/kdb_install.sh

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
ver() {
6+
printf "%3d%03d%03d%03d" $(echo "$1" | tr '.' ' ');
7+
}
8+
9+
# Sets GFX_ARCH to default if not set
10+
# Convert ; seperated string to array
11+
if [ -z "$GFX_ARCH" ]; then
12+
echo "WARNING: missing env var GFX_ARCH, using default (this will take longer)"
13+
GFX_ARCHS=("gfx900" "gfx906" "gfx908" "gfx90a" "gfx942" "gfx1030")
14+
else
15+
# Convert ; seperated string to array
16+
IFS=';' read -ra GFX_ARCHS <<< "$GFX_ARCH"
17+
fi
18+
19+
# Sets ROCM_VERSION to "latest" if not set
20+
if [ -z "$ROCM_VERSION" ]; then
21+
echo "WARNING: missing env var ROCM_VERSION, using latest kdb repo (NOT RECOMMENDED)"
22+
ROCM_VERSION="latest"
23+
fi
24+
25+
# Set PyTorch version and wheel install path
26+
TORCH_INSTALL_PATH=$(uv pip show torch | grep Location | cut -d" " -f 2)
27+
28+
# Check if Torch installation path exists
29+
if [ ! -d "$TORCH_INSTALL_PATH" ]; then
30+
echo "Error: Torch installation path '$TORCH_INSTALL_PATH' does not exist."
31+
exit 1
32+
fi
33+
34+
# Print variable overview
35+
echo "ROCM version: $ROCM_VERSION"
36+
echo "GFX architectures: ${GFX_ARCHS[@]}"
37+
echo "PyTorch installation path: $TORCH_INSTALL_PATH"
38+
39+
# Create directory for extraction
40+
EXTRACT_DIR=extract_miopen_dbs
41+
rm -rf $EXTRACT_DIR
42+
mkdir -p "$EXTRACT_DIR" && cd "$EXTRACT_DIR"
43+
44+
if [[ -f /etc/lsb-release ]]; then
45+
# Exit if not 20.04, 22.04, or 24.04
46+
source /etc/lsb-release
47+
echo "DISTRIB_RELEASE: $DISTRIB_RELEASE"
48+
if [[ "$DISTRIB_RELEASE" != "20.04" && "$DISTRIB_RELEASE" != "22.04" ]]; then
49+
if [[ "$ROCM_VERSION" != "latest" && $(ver $ROCM_VERSION) -lt $(ver 6.2) && "$DISTRIB_RELEASE" == "24.04" ]]; then
50+
echo "ERROR: Unsupported Ubuntu version."
51+
exit 1
52+
fi
53+
fi
54+
55+
for arch in "${GFX_ARCHS[@]}"; do
56+
# Download MIOpen .kdbs for ROCm version and GPU architecture on ubuntu
57+
echo "Downloading .kdb files for rocm-$ROCM_VERSION ($arch arch) ..."
58+
wget -q -r -np -nd -A miopen-hip-$arch*kdb_*$DISTRIB_RELEASE*deb \
59+
https://repo.radeon.com/rocm/apt/$ROCM_VERSION/pool/main/m/
60+
61+
# Check if files were downloaded. No KDB files in repo.radeon will result in error.
62+
if ! ls miopen-hip-$arch*kdb_*$DISTRIB_RELEASE*deb 1> /dev/null 2>&1; then
63+
echo -e "ERROR: No MIOpen kernel database files found for $arch\nPlease check https://repo.radeon.com/rocm/apt/$ROCM_VERSION/pool/main/m/ for supported architectures"
64+
exit 1
65+
fi
66+
done
67+
68+
# Extract all .deb files to local directory
69+
echo "Extracting deb packages for ${GFX_ARCHS[@]} ..."
70+
for deb_file in `ls *deb`; do
71+
echo "Extracting $deb_file..."
72+
dpkg-deb -xv "$deb_file" . > /dev/null 2>&1
73+
done
74+
75+
elif [[ -f /etc/centos-release || -f /etc/redhat-release ]]; then
76+
# Centos kdbs
77+
source /etc/os-release && RHEL_VERSION="$VERSION_ID"
78+
RHEL_MAJOR_VERSION=${RHEL_VERSION%%.*}
79+
echo "RHEL_VERSION: $RHEL_VERSION; RHEL_MAJOR_VERSION: $RHEL_MAJOR_VERSION"
80+
if [[ ! "$RHEL_VERSION" =~ ^(8|9) ]]; then
81+
echo "ERROR: Unsupported CentOS/RHEL release"
82+
fi
83+
for arch in "${GFX_ARCHS[@]}"; do
84+
# Download MIOpen .kdbs for ROCm version and GPU architecture on centos
85+
echo "Downloading .kdb files for rocm-$ROCM_VERSION ($arch arch) ..."
86+
wget -q -r -np -nd -A miopen-hip-$arch*kdb-[0-9]*rpm \
87+
https://repo.radeon.com/rocm/rhel${RHEL_MAJOR_VERSION}/$ROCM_VERSION/main
88+
89+
# Check if files were downloaded. No KDB files in repo.radeon will result in error.
90+
if ! ls miopen-hip-$arch*kdb-*rpm 1> /dev/null 2>&1; then
91+
echo -e "ERROR: No MIOpen kernel database files found for $arch\nPlease check https://repo.radeon.com/rocm/rhel${RHEL_MAJOR_VERSION}/$ROCM_VERSION/main for supported architectures"
92+
exit 1
93+
fi
94+
done
95+
96+
# Extract all RPM files to current directory
97+
echo "Extracting rpm packages for ${GFX_ARCHS[@]} ..."
98+
for rpm_file in `ls *rpm`; do
99+
echo "Extracting $rpm_file..."
100+
rpm2cpio "$rpm_file" | cpio -idmv 2> /dev/null
101+
done
102+
else
103+
echo "ERROR: Unsupported operating system."
104+
exit 1
105+
fi
106+
107+
# Copy miopen db files to PyTorch installation path
108+
echo "Copying kdb files to ${TORCH_INSTALL_PATH}/torch/share"
109+
cp -ra opt/rocm-*/share/miopen $TORCH_INSTALL_PATH/torch/share
110+
111+
# Remove downloaded files and extract directory
112+
cd .. && rm -rf $EXTRACT_DIR
113+
echo "Successfully installed MIOpen kernel database files"
114+

docker/rocm/tensible_install.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Downloading AUR based Tensible library"
6+
cd /tmp && wget https://archlinux.org/packages/extra/x86_64/rocblas/download -O rocblas.tar.zst
7+
echo "Done downloading, the script will proceed to install the library files"
8+
9+
# Download and extract the library
10+
tar --zstd --no-overwrite-dir -xvf rocblas.tar.zst && rm rocblas.tar.zst
11+
rm -rf /app/.venv/lib/python3.12/site-packages/torch/lib/rocblas/library/
12+
mv ./opt/rocm/lib/rocblas/library/ /app/.venv/lib/python3.12/site-packages/torch/lib/rocblas/
13+
rm -rf /tmp/opt /tmp/usr
14+
echo "Done.

0 commit comments

Comments
 (0)