Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions maestro.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Bootstrap: docker
From: ubuntu:22.04

%post

# Install dependencies
apt-get -y update
apt-get install -y software-properties-common
apt-get upgrade -y
apt-get install -y build-essential python3 python3-pip git wget clang lld libzstd-dev libomp-dev
python3 -m pip install --upgrade pip
python3 -m pip install 'cmake==3.22'

# Add GitHub trusted host
mkdir -p ~/.ssh
touch ~/.ssh/known_hosts
ssh-keyscan github.com >> ~/.ssh/known_hosts
chmod 700 ~/.ssh
chmod 644 ~/.ssh/known_hosts

# Install ROCm
mkdir --parents --mode=0755 /etc/apt/keyrings
wget --no-check-certificate https://repo.radeon.com/rocm/rocm.gpg.key -O - | \
gpg --dearmor | tee /etc/apt/keyrings/rocm.gpg > /dev/null

echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/6.3.2 jammy main" \
| tee --append /etc/apt/sources.list.d/rocm.list

printf "Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600\n" | tee /etc/apt/preferences.d/rocm-pin-600

apt-get -y update
ROCM_VERSION=$(apt-cache search rocm-dev[0-9] | awk '{print $1}' | sed 's/rocm-dev//g')
apt-get install -y rocm-dev6.3.2 rocm-llvm-dev6.3.2 rocm-hip-runtime-dev6.3.2 rocm-smi-lib6.3.2 rocminfo6.3.2
export PATH=/opt/rocm/bin:$PATH
export LD_LIBRARY_PATH=/opt/rocm/lib:$LD_LIBRARY_PATH
export ROCM_PATH=/opt/rocm

# Install logduration
export SSH_AUTH_SOCK={{ SSH_AUTH_SOCK }}
cd /root
git clone -v git@github.com:AARInternal/logduration.git
cd logduration
git submodule update --init --recursive
mkdir -p build
cmake -DCMAKE_INSTALL_PREFIX=/opt/logduration -DCMAKE_PREFIX_PATH=${ROCM_PATH} -DLLVM_INSTALL_DIR=/opt/rocm/llvm -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -S . -B build
cmake --build build --target install

# Install rocprof-compute
cd /root
git clone -v git@github.com:ROCm/rocprofiler-compute.git
cd rocprofiler-compute
export INSTALL_DIR=/opt/rocprofiler-compute
python3 -m pip install -t ${INSTALL_DIR}/python-libs -r requirements.txt
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}/3.0.0 \
-DPYTHON_DEPS=${INSTALL_DIR}/python-libs \
-DMOD_INSTALL_PATH=${INSTALL_DIR}/modulefiles/rocprofiler-compute ..
make install
export PATH=${INSTALL_DIR}/3.0.0/bin:$PATH

# Install guided-tuning (JBs tool)
cd /root
git clone -v git@github.com:AARInternal/guided-tuning.git
python3 -m pip install pandas duckdb
21 changes: 21 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

timestamp=$(date +"%Y%m%d_%H%M%S")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we add this?

Suggested change
# Make sure we start the SSH agent
eval `ssh-agent -s`
[ -f ~/.ssh/id_rsa ] && ssh-add ~/.ssh/id_rsa
[ -f ~/.ssh/id_ed25519 ] && ssh-add ~/.ssh/id_ed25519

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, but I've found scripts like this can inadvertently create duplicate ssh-agents. For my own usage, I use a script similar to this in my ~/.bashrc:

if [ ! -S ~/.ssh/ssh_auth_sock ]; then
    eval `ssh-agent` > /dev/null
    ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
ssh-add -l > /dev/null || ssh-add

This way, we're always re-using the same ssh-agent. Let me find a middle ground between both of these solutions and add it to the script

# Auto config SSH agent
if [ ! -S ~/.ssh/ssh_auth_sock ]; then
eval `ssh-agent` > /dev/null
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
[ -f ~/.ssh/id_rsa ] && ssh-add ~/.ssh/id_rsa
[ -f ~/.ssh/id_ed25519 ] && ssh-add ~/.ssh/id_ed25519

ssh_auth_sock_path=$(readlink -f "$SSH_AUTH_SOCK")
# Build the Singularity container
# --build-arg SSH_AUTH_SOCK=$SSH_AUTH_SOCK is used to pass the SSH agent socket to the container
# (advantage of this method is that the key is at no point copied to the container image.)
# If your SSH_AUTH_SOCK will not already bound to the container, and is available at /run/..., add `--bind /run` to the build command
apptainer build \
--build-arg SSH_AUTH_SOCK=${ssh_auth_sock_path} \
"maestro_${timestamp}.sif" maestro.def