Skip to content

Commit a1fb7ec

Browse files
committed
add change base of image
- remove invaalid command from runscript - add unzip
1 parent 39f7528 commit a1fb7ec

2 files changed

Lines changed: 170 additions & 3 deletions

File tree

apptainer/build_multi_base.sh

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: MIT
3+
# Generate IntelliPerf definition files from different base images
4+
5+
set -e
6+
7+
# Default values
8+
BASE_IMAGE=""
9+
OUTPUT_NAME=""
10+
DEF_TEMPLATE="intelliperf.def"
11+
SCRIPT_DIR=$(dirname $(realpath $0))
12+
13+
# Preset base images
14+
declare -A PRESETS=(
15+
["composable_kernel"]="rocm/composable_kernel:ck_ub24.04_rocm7.1.1_amd-staging"
16+
["gemm"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
17+
["matrix_transpose1"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
18+
["vllm"]="rocm/vllm:rocm7.0.0_vllm_0.11.2_20251210"
19+
["counting_sketch"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
20+
["global_reduction"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
21+
["silu"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
22+
["Dataset_hip"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
23+
["gpu-kernel-agent"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
24+
["point_to_voxel"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
25+
["diff_gaussian_rasterization"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
26+
["gsplat"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
27+
["histogram"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
28+
["reduction"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
29+
["causal_conv1d_fwd"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
30+
["element_multiply"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
31+
["matrix_transpose"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
32+
["rocm7.0-pytorch"]="rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0"
33+
["rocm7.1-pytorch"]="rocm/pytorch:rocm7.1_ubuntu22.04_py3.10_pytorch_release_2.8.0"
34+
["composable-kernel"]="rocm/composable_kernel:ck_pytorch"
35+
["rocm6.2-pytorch"]="rocm/pytorch:rocm6.2_ubuntu22.04_py3.10_pytorch_release_2.4.0"
36+
["rocm7.0-ubuntu22"]="rocm/rocm-terminal:rocm7.0-ubuntu22.04"
37+
["rocm7.1-ubuntu22"]="rocm/rocm-terminal:rocm7.1-ubuntu22.04"
38+
["rocm7.0-vllm"]="rocm/vllm:rocm7.0.0_vllm_0.11.2_20251210"
39+
40+
)
41+
42+
# Help message
43+
show_help() {
44+
cat << EOF
45+
Usage: $0 [OPTIONS]
46+
47+
Generate IntelliPerf Apptainer definition files from different base images.
48+
49+
OPTIONS:
50+
-b, --base IMAGE Base Docker image (required)
51+
-o, --output NAME Output .def filename (default: intelliperf-<preset>.def)
52+
-t, --template FILE Template .def file (default: intelliperf.def)
53+
-p, --preset NAME Use preset base image (see list below)
54+
-l, --list List available presets
55+
-h, --help Show this help message
56+
57+
PRESETS:
58+
EOF
59+
for preset in "${!PRESETS[@]}"; do
60+
echo " $preset: ${PRESETS[$preset]}"
61+
done | sort
62+
echo ""
63+
echo "EXAMPLES:"
64+
echo " # Generate def file from rocm7.1-pytorch preset"
65+
echo " $0 --preset rocm7.1-pytorch"
66+
echo ""
67+
echo " # Generate def file from custom base image"
68+
echo " $0 --base rocm/pytorch:rocm7.2_ubuntu22.04_py3.10_pytorch_release_2.9.0 --output intelliperf-rocm72.def"
69+
echo ""
70+
echo " # Generate using intelliperf_ck.def template with different base"
71+
echo " $0 --preset rocm7.1-pytorch --template intelliperf_ck.def --output intelliperf-ck-rocm71.def"
72+
}
73+
74+
# Parse arguments
75+
while [[ $# -gt 0 ]]; do
76+
case $1 in
77+
-b|--base)
78+
BASE_IMAGE="$2"
79+
shift 2
80+
;;
81+
-o|--output)
82+
OUTPUT_NAME="$2"
83+
shift 2
84+
;;
85+
-t|--template)
86+
DEF_TEMPLATE="$2"
87+
shift 2
88+
;;
89+
-p|--preset)
90+
PRESET_NAME="$2"
91+
if [[ -z "${PRESETS[$PRESET_NAME]}" ]]; then
92+
echo "Error: Unknown preset '$PRESET_NAME'"
93+
echo "Use --list to see available presets"
94+
exit 1
95+
fi
96+
BASE_IMAGE="${PRESETS[$PRESET_NAME]}"
97+
# Set default output name based on preset if not specified
98+
if [[ -z "$OUTPUT_NAME" ]]; then
99+
OUTPUT_NAME="intelliperf-${PRESET_NAME}.def"
100+
fi
101+
shift 2
102+
;;
103+
-l|--list)
104+
echo "Available presets:"
105+
for preset in "${!PRESETS[@]}"; do
106+
echo " $preset: ${PRESETS[$preset]}"
107+
done | sort
108+
exit 0
109+
;;
110+
-h|--help)
111+
show_help
112+
exit 0
113+
;;
114+
*)
115+
echo "Unknown option: $1"
116+
show_help
117+
exit 1
118+
;;
119+
esac
120+
done
121+
122+
# Validate required arguments
123+
if [[ -z "$BASE_IMAGE" ]]; then
124+
echo "Error: Base image is required (use --base or --preset)"
125+
show_help
126+
exit 1
127+
fi
128+
129+
# Set default output name if not specified
130+
if [[ -z "$OUTPUT_NAME" ]]; then
131+
# Extract a sanitized name from the base image
132+
SANITIZED=$(echo "$BASE_IMAGE" | sed 's/[\/:]/-/g')
133+
OUTPUT_NAME="intelliperf-${SANITIZED}.def"
134+
fi
135+
136+
# Check if template exists
137+
if [[ ! -f "$SCRIPT_DIR/$DEF_TEMPLATE" ]]; then
138+
echo "Error: Template file '$DEF_TEMPLATE' not found in $SCRIPT_DIR"
139+
exit 1
140+
fi
141+
142+
echo "=========================================="
143+
echo "IntelliPerf Definition File Generator"
144+
echo "=========================================="
145+
echo "Base Image: $BASE_IMAGE"
146+
echo "Template: $DEF_TEMPLATE"
147+
echo "Output: $OUTPUT_NAME"
148+
echo "=========================================="
149+
150+
# Replace the 'From:' line in the template and save to output
151+
sed "s|^From:.*|From: ${BASE_IMAGE}|" "$SCRIPT_DIR/$DEF_TEMPLATE" > "$SCRIPT_DIR/$OUTPUT_NAME"
152+
153+
if [[ $? -eq 0 ]]; then
154+
echo ""
155+
echo "=========================================="
156+
echo "Definition file generated successfully!"
157+
echo "Saved to: $SCRIPT_DIR/$OUTPUT_NAME"
158+
echo "=========================================="
159+
echo ""
160+
echo "To build the container:"
161+
echo " apptainer build ${OUTPUT_NAME%.def}.sif $SCRIPT_DIR/$OUTPUT_NAME"
162+
else
163+
echo ""
164+
echo "=========================================="
165+
echo "Generation failed!"
166+
echo "=========================================="
167+
exit 1
168+
fi

apptainer/intelliperf.def

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ From: rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0
2222

2323
# Install additional system dependencies
2424
apt-get -y update
25-
apt-get install -y software-properties-common git wget clang lld libzstd-dev libomp-dev vim libdwarf-dev gdb tmux cmake
25+
apt-get install -y software-properties-common git wget clang lld libzstd-dev libomp-dev vim libdwarf-dev gdb tmux cmake unzip
2626

2727
# Upgrade pip
2828
pip install --upgrade pip
2929

3030
# Install additional Python packages for intelliperf
31-
pip install --no-cache-dir \
31+
pip install --upgrade --ignore-installed --no-cache-dir \
3232
astunparse==1.6.2 \
3333
colorlover \
3434
dash-bootstrap-components \
@@ -69,5 +69,4 @@ From: rocm/pytorch:rocm7.0_ubuntu22.04_py3.10_pytorch_release_2.8.0
6969

7070
%runscript
7171
echo "Welcome to IntelliPerf with ROCm 7.0!"
72-
source /opt/conda/bin/activate py_3.10
7372
exec "$@"

0 commit comments

Comments
 (0)