Skip to content

Commit 5c799f9

Browse files
committed
Support user space installation for rocm
1 parent d9a30dc commit 5c799f9

7 files changed

Lines changed: 75 additions & 10 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:45:13*
3+
*Last updated: 2026-04-23 01:58:32*
44

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

script/get-amdclang/customize.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ def preprocess(i):
3131
if os.path.isdir(llvm_bin):
3232
search_paths.append(llvm_bin)
3333

34+
# Check custom install prefix (from install-rocm cache)
35+
install_prefix = env.get('MLC_ROCM_INSTALL_PREFIX', '')
36+
if install_prefix:
37+
prefix_opt = os.path.join(install_prefix, 'opt')
38+
for p in [os.path.join(prefix_opt, 'rocm', 'llvm', 'bin')] + sorted(glob.glob(os.path.join(prefix_opt, 'rocm-*', 'llvm', 'bin')), reverse=True):
39+
if os.path.isdir(p) and p not in search_paths:
40+
search_paths.append(p)
41+
3442
# Also check standard paths
3543
for p in ['/opt/rocm/llvm/bin'] + sorted(glob.glob('/opt/rocm-*/llvm/bin'), reverse=True):
3644
if os.path.isdir(p) and p not in search_paths:

script/get-rocm/customize.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@ def preprocess(i):
1414
file_name = 'rocminfo.exe' if os_info['platform'] == 'windows' else 'rocminfo'
1515
env['FILE_NAME'] = file_name
1616

17-
# Build search paths: check /opt/rocm/bin and any versioned /opt/rocm-*/bin
17+
# Build search paths: check custom install prefix, then /opt/rocm/bin and versioned /opt/rocm-*/bin
1818
rocm_paths = []
19+
20+
# Check custom install prefix (from install-rocm cache)
21+
install_prefix = env.get('MLC_ROCM_INSTALL_PREFIX', '')
22+
if install_prefix:
23+
prefix_opt = os.path.join(install_prefix, 'opt')
24+
for p in [os.path.join(prefix_opt, 'rocm', 'bin')] + sorted(glob.glob(os.path.join(prefix_opt, 'rocm-*', 'bin')), reverse=True):
25+
if os.path.isdir(p):
26+
rocm_paths.append(p)
27+
28+
# Standard paths
1929
if os.path.isdir("/opt/rocm/bin"):
2030
rocm_paths.append("/opt/rocm/bin")
2131
for p in sorted(glob.glob("/opt/rocm-*/bin"), reverse=True):

script/install-rocm/customize.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,47 @@ def preprocess(i):
88
if os_info['platform'] == 'windows':
99
return {'return': 1, 'error': 'Windows is not supported in this script yet'}
1010

11+
env = i['env']
12+
13+
# Determine install prefix:
14+
# 1. If explicitly set via input, use that
15+
# 2. If sudo is available, default to "/" (installs to /opt/rocm)
16+
# 3. Otherwise, use MLC cache directory (no root needed)
17+
install_prefix = env.get('MLC_ROCM_INSTALL_PREFIX', '').strip()
18+
if install_prefix == '':
19+
if env.get('MLC_SUDO_USER', '') == 'yes':
20+
install_prefix = '/'
21+
else:
22+
install_prefix = os.getcwd()
23+
24+
env['MLC_ROCM_INSTALL_PREFIX'] = install_prefix
25+
1126
return {'return': 0}
1227

1328

1429
def postprocess(i):
1530

1631
env = i['env']
1732

18-
# Check standard and versioned ROCm install paths
33+
install_prefix = env.get('MLC_ROCM_INSTALL_PREFIX', '/')
34+
35+
# Check install prefix paths first, then standard /opt paths
36+
search_dirs = []
37+
38+
# Custom prefix: ROCm installs to <prefix>/opt/rocm-<version>
39+
prefix_opt = os.path.join(install_prefix, 'opt')
40+
if os.path.isdir(prefix_opt):
41+
for p in [os.path.join(prefix_opt, 'rocm', 'bin')] + sorted(glob.glob(os.path.join(prefix_opt, 'rocm-*', 'bin')), reverse=True):
42+
if os.path.isdir(p):
43+
search_dirs.append(p)
44+
45+
# Standard paths as fallback
46+
for p in ["/opt/rocm/bin"] + sorted(glob.glob("/opt/rocm-*/bin"), reverse=True):
47+
if os.path.isdir(p) and p not in search_dirs:
48+
search_dirs.append(p)
49+
1950
installed_path = ""
20-
for candidate in ["/opt/rocm/bin"] + sorted(glob.glob("/opt/rocm-*/bin"), reverse=True):
51+
for candidate in search_dirs:
2152
if os.path.isfile(os.path.join(candidate, "rocminfo")):
2253
installed_path = candidate
2354
break

script/install-rocm/meta.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,21 @@ tags:
1414
cache: true
1515
clean_files: []
1616

17+
# Input mapping
18+
input_mapping:
19+
rocm_install_prefix: MLC_ROCM_INSTALL_PREFIX
20+
1721
# Environment
1822
env: {}
1923
new_env_keys:
2024
- MLC_ROMLC_*
25+
- MLC_ROCM_INSTALL_PREFIX
2126
- +PATH
2227

2328
# Dependencies
2429
deps:
2530
- tags: detect,os
31+
- tags: detect,sudo
2632

2733
# Versions
2834
default_version: 7.2.2

script/install-rocm/run-rhel.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ if [[ ${major_version} -ge 7 ]]; then
2222
test $? -eq 0 || exit 1
2323
chmod +x /tmp/${runfile_name}
2424

25-
# Install ROCm via runfile (no driver for CPU-only compatibility)
26-
echo "Installing ROCm ${MLC_VERSION} via runfile..."
27-
sudo bash /tmp/${runfile_name} deps=install target="/" rocm postrocm
25+
# Install ROCm via runfile
26+
install_prefix="${MLC_ROCM_INSTALL_PREFIX:-/}"
27+
echo "Installing ROCm ${MLC_VERSION} via runfile to target=${install_prefix} ..."
28+
if [[ "${install_prefix}" == "/" ]]; then
29+
sudo bash /tmp/${runfile_name} deps=install target="/" rocm postrocm
30+
else
31+
bash /tmp/${runfile_name} deps=install target="${install_prefix}" rocm postrocm
32+
fi
2833
test $? -eq 0 || exit 1
2934

3035
rm -f /tmp/${runfile_name}

script/install-rocm/run-ubuntu.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ if [[ ${major_version} -ge 7 ]]; then
3131
test $? -eq 0 || exit 1
3232
chmod +x /tmp/${runfile_name}
3333

34-
# Install ROCm via runfile (no driver for CPU-only compatibility)
35-
echo "Installing ROCm ${MLC_VERSION} via runfile..."
36-
sudo bash /tmp/${runfile_name} deps=install target="/" rocm postrocm
34+
# Install ROCm via runfile
35+
install_prefix="${MLC_ROCM_INSTALL_PREFIX:-/}"
36+
echo "Installing ROCm ${MLC_VERSION} via runfile to target=${install_prefix} ..."
37+
if [[ "${install_prefix}" == "/" ]]; then
38+
sudo bash /tmp/${runfile_name} deps=install target="/" rocm postrocm
39+
else
40+
bash /tmp/${runfile_name} deps=install target="${install_prefix}" rocm postrocm
41+
fi
3742
test $? -eq 0 || exit 1
3843

3944
rm -f /tmp/${runfile_name}

0 commit comments

Comments
 (0)