Skip to content

Commit 5f40d8c

Browse files
authored
Build Primus Docker (Private) (#247)
1 parent 6af77cc commit 5f40d8c

File tree

2 files changed

+92
-1
lines changed

2 files changed

+92
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
- "v*"
1010
pull_request:
1111

12+
env:
13+
PRIMUS_TURBO_COMMIT: a97e986f01893fec5789243400c7046d18591ba9 # chore: update aiter to fix pybind11 issue (#132)
14+
1215
jobs:
1316
code-lint:
1417
runs-on: ubuntu-latest
@@ -47,20 +50,83 @@ jobs:
4750
if: always()
4851
with:
4952
options: "--check --diff --color --verbose --line-length=110"
53+
54+
build-docker:
55+
needs: [code-lint]
56+
runs-on: build-docker
57+
strategy:
58+
matrix:
59+
python-version: ["3.12"]
60+
steps:
61+
- run: echo "🎉 Begin Build Primus Docker Image."
62+
- uses: actions/checkout@v4
63+
with:
64+
submodules: recursive
65+
- name: Show Environment Info
66+
run: |
67+
echo "Hostname: $(hostname)"
68+
echo "PWD: $(pwd)"
69+
echo "HOME: $HOME"
70+
echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE"
71+
echo "Runner Temp Dir: $RUNNER_TEMP"
72+
echo "Runner Tool Cache: $RUNNER_TOOL_CACHE"
73+
- name: Parse Commit Info
74+
run: |
75+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
76+
echo "IMAGE_TAG=pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
77+
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
78+
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
79+
elif [[ "${{ github.event_name }}" == "release" ]]; then
80+
TAG_NAME="${{ github.ref }}"
81+
TAG="${TAG_NAME#refs/tags/}"
82+
echo "IMAGE_TAG=$TAG" >> $GITHUB_ENV
83+
else
84+
echo "IMAGE_TAG=others" >> $GITHUB_ENV
85+
fi
86+
- name: Build and Push Docker Image
87+
run: |
88+
echo "> Login to Docker Hub"
89+
docker login -u tasimage -p ${{ secrets.PRIMUS_DOCKER_HUB_TOKEN }}
90+
91+
echo "> Build Docker Image with tag: ${{ env.IMAGE_TAG }}"
92+
start_time=$(date +%s)
93+
docker build -f $GITHUB_WORKSPACE/.github/workflows/docker/Dockerfile \
94+
-t tasimage/primus:${{env.IMAGE_TAG}} \
95+
--build-arg PRIMUS_TURBO_COMMIT=${PRIMUS_TURBO_COMMIT} .
96+
end_time=$(date +%s)
97+
elapsed=$((end_time - start_time))
98+
echo "⏱️ [build primus docker] Total elapsed time: ${elapsed} seconds"
99+
100+
echo "> Docker tag image for Docker Hub"
101+
docker tag tasimage/primus:${{env.IMAGE_TAG}} docker.io/tasimage/primus:${{env.IMAGE_TAG}}
102+
103+
echo "> Docker push to Docker Hub"
104+
start_time=$(date +%s)
105+
docker push docker.io/tasimage/primus:${{env.IMAGE_TAG}}
106+
end_time=$(date +%s)
107+
elapsed=$((end_time - start_time))
108+
echo "⏱️ [push primus docker] Total elapsed time: ${elapsed} seconds"
109+
110+
# echo "> Docker cleanup local images"
111+
# docker rmi tasimage/primus:${{env.IMAGE_TAG}}
112+
# echo "> build-docker success"
113+
50114
run-unittest:
51115
env:
52116
PRIMUS_WORKDIR: /apps/tas/0_public/primus_k8s_ci
53117
needs: [code-lint]
54118
runs-on: [tas-k8s]
55119
steps:
56120
- run: echo "🎉 Begin Primus-Turbo Checkout."
121+
- name: Set commit hash to env
122+
run: echo "PRIMUS_TURBO_COMMIT=${PRIMUS_TURBO_COMMIT}" >> $GITHUB_ENV
57123
- name: Checkout Repo Primus-Turbo
58124
uses: actions/checkout@v4
59125
with:
60126
repository: AMD-AIG-AIMA/Primus-Turbo
61127
submodules: "recursive"
62128
path: Primus-Turbo
63-
ref: a97e986f01893fec5789243400c7046d18591ba9 # chore: update aiter to fix pybind11 issue (#132)
129+
ref: ${{ env.PRIMUS_TURBO_COMMIT }}
64130
- run: echo "Begin Primus-Turbo Install."
65131
- name: Install Primus-Turbo
66132
run: |
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Base image
2+
FROM docker.io/rocm/megatron-lm:v25.9_gfx942
3+
4+
# Specify the commit of Primus-Turbo when building: docker build --build-arg PRIMUS_TURBO_COMMIT=xxx .)
5+
ARG PRIMUS_TURBO_COMMIT
6+
7+
# Install basic dependencies
8+
RUN apt-get update
9+
10+
# Clone and install the Primus-Turbo
11+
WORKDIR /opt
12+
RUN mkdir -p /opt && cd /opt && \
13+
git clone https://github.com/AMD-AGI/Primus-Turbo.git && \
14+
cd Primus-Turbo && \
15+
git checkout ${PRIMUS_TURBO_COMMIT} && \
16+
git submodule update --init --recursive && \
17+
pip3 install -r requirements.txt && \
18+
GPU_ARCHS="gfx942;gfx950" pip3 install --no-build-isolation .
19+
20+
21+
# Set the default working directory
22+
WORKDIR /opt
23+
24+
# check the installed Primus-Turbo package
25+
RUN python3 -m pip show primus-turbo || true

0 commit comments

Comments
 (0)