Skip to content

Commit 9b31971

Browse files
committed
Use download,file for downloading rocm file
1 parent 5c799f9 commit 9b31971

5 files changed

Lines changed: 62 additions & 32 deletions

File tree

script/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MLCommons Automation Scripts
22

3-
*Last updated: 2026-04-23 01:58:32*
3+
*Last updated: 2026-04-23 02:01:43*
44

55
This directory contains automation scripts for MLPerf benchmarks, AI/ML workflows, and development operations.
66

script/install-rocm/customize.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
from mlc import utils
22
import os
33
import glob
4+
import re
5+
6+
try:
7+
from urllib.request import urlopen
8+
except ImportError:
9+
from urllib2 import urlopen
410

511

612
def preprocess(i):
@@ -23,6 +29,35 @@ def preprocess(i):
2329

2430
env['MLC_ROCM_INSTALL_PREFIX'] = install_prefix
2531

32+
# For ROCm 7+, resolve the runfile download URL
33+
version = env.get('MLC_VERSION', '')
34+
major_version = int(version.split('.')[0]) if version else 0
35+
36+
if major_version >= 7:
37+
os_flavor = env.get('MLC_HOST_OS_FLAVOR', 'ubuntu')
38+
os_version = env.get('MLC_HOST_OS_VERSION', '')
39+
40+
if 'ubuntu' in os_flavor or 'debian' in os_flavor:
41+
runfile_base_url = f"https://repo.radeon.com/rocm/installer/rocm-runfile-installer/rocm-rel-{version}/ubuntu/{os_version}/"
42+
else:
43+
runfile_base_url = f"https://repo.radeon.com/rocm/installer/rocm-runfile-installer/rocm-rel-{version}/rhel/{os_version}/"
44+
45+
# Fetch directory listing to find the runfile name
46+
try:
47+
response = urlopen(runfile_base_url)
48+
html = response.read().decode('utf-8')
49+
match = re.search(r'(rocm-installer[^"]+\.run)', html)
50+
if match:
51+
runfile_name = match.group(1)
52+
env['MLC_DOWNLOAD_URL'] = runfile_base_url + runfile_name
53+
env['MLC_DOWNLOAD_FILENAME'] = runfile_name
54+
env['MLC_ROCM_RUNFILE_NAME'] = runfile_name
55+
env['MLC_ROCM_USE_RUNFILE'] = 'yes'
56+
else:
57+
return {'return': 1, 'error': f'Could not find ROCm runfile installer at {runfile_base_url}'}
58+
except Exception as e:
59+
return {'return': 1, 'error': f'Failed to fetch ROCm runfile listing from {runfile_base_url}: {e}'}
60+
2661
return {'return': 0}
2762

2863

script/install-rocm/meta.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ deps:
3030
- tags: detect,os
3131
- tags: detect,sudo
3232

33+
# Prehook dependencies
34+
prehook_deps:
35+
- tags: download,file
36+
enable_if_env:
37+
MLC_ROCM_USE_RUNFILE:
38+
- 'yes'
39+
env:
40+
MLC_DOWNLOAD_FILENAME: <<<MLC_ROCM_RUNFILE_NAME>>>
41+
force_env_keys:
42+
- MLC_DOWNLOAD_URL
43+
- MLC_DOWNLOAD_FILENAME
44+
3345
# Versions
3446
default_version: 7.2.2
3547
versions:

script/install-rocm/run-rhel.sh

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,25 @@
66
major_version="${MLC_VERSION%%.*}"
77

88
if [[ ${major_version} -ge 7 ]]; then
9-
# ROCm 7.x: Use runfile installer
10-
rhel_ver="${MLC_HOST_OS_VERSION}"
11-
runfile_base_url="https://repo.radeon.com/rocm/installer/rocm-runfile-installer/rocm-rel-${MLC_VERSION}/rhel/${rhel_ver}/"
12-
13-
# Get the runfile name from the directory listing
14-
runfile_name=$(wget -q -O - "${runfile_base_url}" | grep -oP 'rocm-installer[^"]+\.run' | head -1)
15-
if [[ -z "${runfile_name}" ]]; then
16-
echo "ERROR: Could not find ROCm runfile installer at ${runfile_base_url}"
9+
# ROCm 7.x: Use runfile installer (downloaded via download,file script)
10+
runfile_path="${MLC_DOWNLOAD_DOWNLOADED_PATH}"
11+
if [[ -z "${runfile_path}" || ! -f "${runfile_path}" ]]; then
12+
echo "ERROR: ROCm runfile not found at ${runfile_path}"
1713
exit 1
1814
fi
1915

20-
echo "Downloading ROCm ${MLC_VERSION} runfile installer: ${runfile_name}"
21-
wget -q "${runfile_base_url}${runfile_name}" -O /tmp/${runfile_name}
22-
test $? -eq 0 || exit 1
23-
chmod +x /tmp/${runfile_name}
16+
chmod +x "${runfile_path}"
2417

2518
# Install ROCm via runfile
2619
install_prefix="${MLC_ROCM_INSTALL_PREFIX:-/}"
2720
echo "Installing ROCm ${MLC_VERSION} via runfile to target=${install_prefix} ..."
2821
if [[ "${install_prefix}" == "/" ]]; then
29-
sudo bash /tmp/${runfile_name} deps=install target="/" rocm postrocm
22+
sudo bash "${runfile_path}" deps=install target="/" rocm postrocm
3023
else
31-
bash /tmp/${runfile_name} deps=install target="${install_prefix}" rocm postrocm
24+
bash "${runfile_path}" deps=install target="${install_prefix}" rocm postrocm
3225
fi
3326
test $? -eq 0 || exit 1
3427

35-
rm -f /tmp/${runfile_name}
36-
3728
else
3829
# ROCm 5.x/6.x: Use package manager method
3930
mainversion="${MLC_HOST_OS_VERSION%%.*}"

script/install-rocm/run-ubuntu.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,25 @@ fi
1616
major_version="${MLC_VERSION%%.*}"
1717

1818
if [[ ${major_version} -ge 7 ]]; then
19-
# ROCm 7.x: Use runfile installer
20-
runfile_base_url="https://repo.radeon.com/rocm/installer/rocm-runfile-installer/rocm-rel-${MLC_VERSION}/ubuntu/${ubuntu_ver}/"
21-
22-
# Get the runfile name from the directory listing
23-
runfile_name=$(wget -q -O - "${runfile_base_url}" | grep -oP 'rocm-installer[^"]+\.run' | head -1)
24-
if [[ -z "${runfile_name}" ]]; then
25-
echo "ERROR: Could not find ROCm runfile installer at ${runfile_base_url}"
19+
# ROCm 7.x: Use runfile installer (downloaded via download,file script)
20+
runfile_path="${MLC_DOWNLOAD_DOWNLOADED_PATH}"
21+
if [[ -z "${runfile_path}" || ! -f "${runfile_path}" ]]; then
22+
echo "ERROR: ROCm runfile not found at ${runfile_path}"
2623
exit 1
2724
fi
2825

29-
echo "Downloading ROCm ${MLC_VERSION} runfile installer: ${runfile_name}"
30-
wget -q "${runfile_base_url}${runfile_name}" -O /tmp/${runfile_name}
31-
test $? -eq 0 || exit 1
32-
chmod +x /tmp/${runfile_name}
26+
chmod +x "${runfile_path}"
3327

3428
# Install ROCm via runfile
3529
install_prefix="${MLC_ROCM_INSTALL_PREFIX:-/}"
3630
echo "Installing ROCm ${MLC_VERSION} via runfile to target=${install_prefix} ..."
3731
if [[ "${install_prefix}" == "/" ]]; then
38-
sudo bash /tmp/${runfile_name} deps=install target="/" rocm postrocm
32+
sudo bash "${runfile_path}" deps=install target="/" rocm postrocm
3933
else
40-
bash /tmp/${runfile_name} deps=install target="${install_prefix}" rocm postrocm
34+
bash "${runfile_path}" deps=install target="${install_prefix}" rocm postrocm
4135
fi
4236
test $? -eq 0 || exit 1
4337

44-
rm -f /tmp/${runfile_name}
45-
4638
else
4739
# ROCm 5.x/6.x: Use package manager method
4840
sudo mkdir --parents --mode=0755 /etc/apt/keyrings

0 commit comments

Comments
 (0)