Skip to content

Commit 19f65ea

Browse files
authored
[Docker] Add dstackai/amd-smi image (#2611)
1 parent ed70598 commit 19f65ea

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build AMD SMI Docker image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
image_name:
7+
description: "Docker image name"
8+
required: true
9+
default: "dstackai/amd-smi"
10+
rocm_version:
11+
description: "ROCm version"
12+
required: true
13+
default: "6.4"
14+
dstack_revision:
15+
description: "Docker image revision"
16+
required: true
17+
default: 0
18+
19+
jobs:
20+
build-amd-smi:
21+
defaults:
22+
run:
23+
working-directory: docker/amd-smi
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
- name: Login to DockerHub
31+
uses: docker/login-action@v3
32+
with:
33+
username: ${{ secrets.DOCKERHUB_USERNAME }}
34+
password: ${{ secrets.DOCKERHUB_TOKEN }}
35+
- name: Build and upload to DockerHub
36+
run: |
37+
IMAGE_NAME=${{ inputs.image_name }}
38+
docker buildx build . \
39+
--load \
40+
--provenance=false \
41+
--platform linux/amd64 \
42+
--build-arg IMAGE_NAME=${IMAGE_NAME} \
43+
--build-arg UBUNTU_VERSION=noble \
44+
--build-arg ROCM_VERSION=${{ inputs.rocm_version }} \
45+
--build-arg DSTACK_REVISION=${{ inputs.dstack_revision }} \
46+
--build-arg BUILD_DATE=$(date --utc --iso-8601=seconds)Z \
47+
--tag ${IMAGE_NAME}:latest
48+
VERSION=$(docker inspect --format '{{ index .Config.Labels "org.opencontainers.image.version" }}' ${IMAGE_NAME})
49+
docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${VERSION}
50+
docker push ${IMAGE_NAME}:${VERSION}
51+
docker push ${IMAGE_NAME}:latest

docker/amd-smi/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ARG UBUNTU_VERSION
2+
3+
FROM ubuntu:${UBUNTU_VERSION}
4+
5+
ARG IMAGE_NAME
6+
ARG UBUNTU_VERSION
7+
ARG ROCM_VERSION
8+
ARG DSTACK_REVISION
9+
ARG BUILD_DATE
10+
11+
ENV PATH="/opt/rocm/bin:${PATH}"
12+
13+
RUN \
14+
export DEBIAN_FRONTEND=noninteractive && \
15+
apt-get update && \
16+
apt-get install -y --no-install-recommends wget ca-certificates && \
17+
base_url="https://repo.radeon.com/amdgpu-install/${ROCM_VERSION}/ubuntu/${UBUNTU_VERSION}/" && \
18+
deb_name=$(wget -qO- "${base_url}" | grep -Po '(?<=href=")amdgpu-install_[^"]+') && \
19+
wget -O amdgpu-install.deb "${base_url}${deb_name}" && \
20+
apt-get install -y --no-install-recommends ./amdgpu-install.deb && \
21+
rm ./amdgpu-install.deb && \
22+
apt-get update && \
23+
apt-get install -y amd-smi-lib
24+
25+
ENTRYPOINT ["/opt/rocm/bin/amd-smi"]
26+
CMD ["--help"]
27+
28+
LABEL org.opencontainers.image.title="${IMAGE_NAME}"
29+
LABEL org.opencontainers.image.version="${ROCM_VERSION}-${DSTACK_REVISION}"
30+
LABEL org.opencontainers.image.created="${BUILD_DATE}"

docker/amd-smi/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# dstack AMD SMI
2+
3+
An Ubuntu-based image with [AMD SMI](https://rocm.docs.amd.com/projects/amdsmi/en/latest/) preinstalled. Suitable for AMD GPU detection.
4+
5+
## Usage
6+
7+
```shell
8+
docker run --rm --device /dev/kfd --device /dev/dri dstackai/amd-smi static
9+
```

0 commit comments

Comments
 (0)