Skip to content

Commit 2df9443

Browse files
tkatilauniemimu
authored andcommitted
gpu: add levelzero application
Signed-off-by: Tuomas Katila <tuomas.katila@intel.com>
1 parent 78f7c95 commit 2df9443

File tree

16 files changed

+2081
-3
lines changed

16 files changed

+2081
-3
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/cmd/gpu_fakedev/ @tkatila @uniemimu @eero-t
1515
/cmd/gpu_plugin/ @tkatila @bart0sh @uniemimu
1616
/cmd/gpu_nfdhook/ @tkatila @bart0sh @uniemimu
17+
/cmd/gpu_levelzero/ @tkatila @eero-t @uniemimu
1718
/cmd/qat_plugin/ @hj-johannes-lee @mythi
1819
/cmd/sgx_plugin/ @hj-johannes-lee @mythi
1920
/cmd/dsa_plugin/ @hj-johannes-lee @ozhuraki @mythi

.github/workflows/lib-validate.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ jobs:
5858
- run: make go-mod-tidy
5959
- run: make BUILDTAGS=kerneldrv
6060
- run: make test BUILDTAGS=kerneldrv
61+
env:
62+
UNITTEST: 1
6163
- run: make check-github-actions
6264
#- name: Codecov report
6365
# run: bash <(curl -s https://codecov.io/bash)

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ cmd/operator/operator
2323

2424
deployments/fpga_admissionwebhook/base/intel-fpga-webhook-certs-secret
2525

26-
*.h
2726
*.gbs.*
2827
*.aocx
2928
*.aocx.*

build/docker/build-image.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ if [ -d $(dirname $0)/../../vendor ] ; then
2929
BUILD_ARGS="${BUILD_ARGS} --build-arg DIR=/go/src/github.com/intel/intel-device-plugins-for-kubernetes --build-arg GO111MODULE=off"
3030
fi
3131

32-
BUILD_ARGS="${BUILD_ARGS} --build-arg FINAL_BASE=gcr.io/distroless/static"
32+
BUILD_ARGS="${BUILD_ARGS} \
33+
--build-arg FINAL_BASE=gcr.io/distroless/static \
34+
--build-arg BUILD_BASE=golang:1.23-bookworm \
35+
--build-arg FINAL_BASE_DYN=debian:unstable-slim \
36+
--build-arg ROCKYLINUX=0"
37+
3338
if [ -z "${BUILDER}" -o "${BUILDER}" = 'docker' -o "${BUILDER}" = 'podman' ] ; then
3439
${BUILDER} build --pull -t ${IMG}:${TAG} ${BUILD_ARGS} -f ${DOCKERFILE} .
3540
elif [ "${BUILDER}" = 'buildah' ] ; then
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
## This is a generated file, do not edit directly. Edit build/docker/templates/intel-gpu-levelzero.Dockerfile.in instead.
2+
##
3+
## Copyright 2022 Intel Corporation. All Rights Reserved.
4+
##
5+
## Licensed under the Apache License, Version 2.0 (the "License");
6+
## you may not use this file except in compliance with the License.
7+
## You may obtain a copy of the License at
8+
##
9+
## http://www.apache.org/licenses/LICENSE-2.0
10+
##
11+
## Unless required by applicable law or agreed to in writing, software
12+
## distributed under the License is distributed on an "AS IS" BASIS,
13+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
## See the License for the specific language governing permissions and
15+
## limitations under the License.
16+
###
17+
ARG CMD=gpu_levelzero
18+
ARG ROCKYLINUX=1
19+
## FINAL_BASE_DYN can be used to configure the base image of the final image.
20+
## The project default is 1) which sets FINAL_BASE_DYN=gcr.io/distroless/cc-debian12
21+
## (see build-image.sh).
22+
## 2) and the default FINAL_BASE is primarily used to build Redhat Certified Openshift Operator container images that must be UBI based.
23+
## The RedHat build tool does not allow additional image build parameters.
24+
ARG BUILD_BASE=rockylinux:9
25+
ARG FINAL_BASE_DYN=registry.access.redhat.com/ubi9/ubi-minimal:9.3
26+
###
27+
FROM ${BUILD_BASE} as builder
28+
ARG DIR=/intel-device-plugins-for-kubernetes
29+
ENV CGO_CFLAGS="-pipe -fno-plt"
30+
ENV CGO_LDFLAGS="-fstack-protector-strong -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now,-z,noexecstack,-z,defs,-s,-w"
31+
ENV CGOFLAGS="-trimpath -mod=readonly -buildmode=pie"
32+
ENV GCFLAGS="all=-spectre=all -N -l"
33+
ENV ASMFLAGS="all=-spectre=all"
34+
ENV LDFLAGS="all=-linkmode=external -s -w"
35+
ARG GOLICENSES_VERSION
36+
ARG CMD
37+
ARG ROCKYLINUX
38+
ARG CGO_VERSION=1.23
39+
RUN mkdir /runtime
40+
RUN if [ $ROCKYLINUX -eq 0 ]; then \
41+
apt-get update && apt-get install --no-install-recommends -y wget libc6-dev ca-certificates ocl-icd-libopencl1 && \
42+
cd /runtime && \
43+
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-level-zero-gpu_1.3.30049.6_amd64.deb && \
44+
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-opencl-icd_24.26.30049.6_amd64.deb && \
45+
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/libigdgmm12_22.3.20_amd64.deb && \
46+
wget -q https://github.com/oneapi-src/level-zero/releases/download/v1.17.6/level-zero-devel_1.17.6+u22.04_amd64.deb && \
47+
wget -q https://github.com/oneapi-src/level-zero/releases/download/v1.17.6/level-zero_1.17.6+u22.04_amd64.deb && \
48+
dpkg --ignore-depends=intel-igc-core,intel-igc-opencl -i *.deb && \
49+
rm -rf /var/lib/apt/lists/\*; \
50+
else \
51+
source /etc/os-release && dnf install -y gcc jq wget 'dnf-command(config-manager)' && \
52+
dnf config-manager --add-repo https://repositories.intel.com/gpu/rhel/${VERSION_ID}/lts/2350/unified/intel-gpu-${VERSION_ID}.repo && \
53+
dnf install -y intel-opencl level-zero level-zero-devel intel-level-zero-gpu intel-gmmlib intel-ocloc && \
54+
dnf clean all && \
55+
LATEST_GO=$(curl --no-progress-meter https://go.dev/dl/?mode=json | jq ".[] | select(.version | startswith(\"go${CGO_VERSION}\")).version" | tr -d "\"") && \
56+
wget -q https://go.dev/dl/$LATEST_GO.linux-amd64.tar.gz -O - | tar -xz -C /usr/local && \
57+
cp -a /etc/OpenCL /usr/lib64/libocloc.so /usr/lib64/libze_intel_gpu.* /usr/lib64/libze_loader.* /usr/lib64/libigdgmm.* /runtime/ && \
58+
mkdir /runtime/licenses/ && cd /usr/share/licenses/ && cp -a level-zero intel-gmmlib intel-level-zero-gpu intel-ocloc /runtime/licenses/; \
59+
fi
60+
ARG EP=/usr/local/bin/intel_gpu_levelzero
61+
ARG CMD
62+
WORKDIR ${DIR}
63+
COPY . .
64+
RUN export PATH=$PATH:/usr/local/go/bin/ && cd cmd/${CMD} && \
65+
GO111MODULE=on CGO_ENABLED=1 go install $CGOFLAGS --gcflags="$GCFLAGS" --asmflags="$ASMFLAGS" --ldflags="$LDFLAGS"
66+
RUN [ $ROCKYLINUX -eq 0 ] && install -D /go/bin/${CMD} /install_root${EP} || install -D /root/go/bin/${CMD} /install_root${EP}
67+
RUN install -D ${DIR}/LICENSE /install_root/licenses/intel-device-plugins-for-kubernetes/LICENSE \
68+
&& if [ ! -d "licenses/$CMD" ] ; then \
69+
GO111MODULE=on go run github.com/google/go-licenses@${GOLICENSES_VERSION} save "./cmd/$CMD" \
70+
--save_path /install_root/licenses/$CMD/go-licenses ; \
71+
else mkdir -p /install_root/licenses/$CMD/go-licenses/ && cd licenses/$CMD && cp -r * /install_root/licenses/$CMD/go-licenses/ ; fi
72+
FROM ${FINAL_BASE_DYN}
73+
ARG CMD
74+
ARG ROCKYLINUX
75+
COPY --from=builder /runtime /runtime
76+
RUN if [ $ROCKYLINUX -eq 0 ]; then \
77+
apt-get update && apt-get install --no-install-recommends -y ocl-icd-libopencl1 && \
78+
rm /runtime/level-zero-devel_*.deb && \
79+
cd /runtime && dpkg --ignore-depends=intel-igc-core,intel-igc-opencl -i *.deb && rm -rf /runtime && \
80+
rm "/lib/x86_64-linux-gnu/libze_validation"* && rm "/lib/x86_64-linux-gnu/libze_tracing_layer"*; \
81+
else \
82+
cp -a /runtime//*.so* /usr/lib64/ && cp -a /runtime/OpenCL /etc/ && cp -a /runtime/licenses/* /usr/share/licenses/; \
83+
fi
84+
COPY --from=builder /install_root /
85+
ENTRYPOINT ["/usr/local/bin/intel_gpu_levelzero"]
86+
LABEL vendor='Intel®'
87+
LABEL version='devel'
88+
LABEL release='1'
89+
LABEL name='intel-gpu-levelzero'
90+
LABEL summary='Intel® GPU levelzero for Kubernetes'
91+
LABEL description='The GPU levelzero container provides access to Levelzero API for the Intel GPU plugin'
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#define _ENTRYPOINT_ /usr/local/bin/intel_gpu_levelzero
2+
3+
ARG CMD=gpu_levelzero
4+
ARG ROCKYLINUX=1
5+
6+
## FINAL_BASE_DYN can be used to configure the base image of the final image.
7+
## The project default is 1) which sets FINAL_BASE_DYN=gcr.io/distroless/cc-debian12
8+
## (see build-image.sh).
9+
## 2) and the default FINAL_BASE is primarily used to build Redhat Certified Openshift Operator container images that must be UBI based.
10+
## The RedHat build tool does not allow additional image build parameters.
11+
ARG BUILD_BASE=rockylinux:9
12+
ARG FINAL_BASE_DYN=registry.access.redhat.com/ubi9/ubi-minimal:9.3
13+
###
14+
15+
FROM ${BUILD_BASE} as builder
16+
17+
ARG DIR=/intel-device-plugins-for-kubernetes
18+
19+
ENV CGO_CFLAGS="-pipe -fno-plt"
20+
ENV CGO_LDFLAGS="-fstack-protector-strong -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now,-z,noexecstack,-z,defs,-s,-w"
21+
ENV CGOFLAGS="-trimpath -mod=readonly -buildmode=pie"
22+
ENV GCFLAGS="all=-spectre=all -N -l"
23+
ENV ASMFLAGS="all=-spectre=all"
24+
ENV LDFLAGS="all=-linkmode=external -s -w"
25+
26+
ARG GOLICENSES_VERSION
27+
ARG CMD
28+
ARG ROCKYLINUX
29+
ARG CGO_VERSION=1.23
30+
31+
RUN mkdir /runtime
32+
33+
RUN if [ $ROCKYLINUX -eq 0 ]; then \N
34+
apt-get update && apt-get install --no-install-recommends -y wget libc6-dev ca-certificates ocl-icd-libopencl1 && \N
35+
cd /runtime && \N
36+
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-level-zero-gpu_1.3.30049.6_amd64.deb && \N
37+
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-opencl-icd_24.26.30049.6_amd64.deb && \N
38+
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/libigdgmm12_22.3.20_amd64.deb && \N
39+
wget -q https://github.com/oneapi-src/level-zero/releases/download/v1.17.6/level-zero-devel_1.17.6+u22.04_amd64.deb && \N
40+
wget -q https://github.com/oneapi-src/level-zero/releases/download/v1.17.6/level-zero_1.17.6+u22.04_amd64.deb && \N
41+
dpkg --ignore-depends=intel-igc-core,intel-igc-opencl -i *.deb && \N
42+
rm -rf /var/lib/apt/lists/\*; \N
43+
else \N
44+
source /etc/os-release && dnf install -y gcc jq wget 'dnf-command(config-manager)' && \N
45+
dnf config-manager --add-repo https://repositories.intel.com/gpu/rhel/${VERSION_ID}/lts/2350/unified/intel-gpu-${VERSION_ID}.repo && \N
46+
dnf install -y intel-opencl level-zero level-zero-devel intel-level-zero-gpu intel-gmmlib intel-ocloc && \N
47+
dnf clean all && \N
48+
LATEST_GO=$(curl --no-progress-meter https://go.dev/dl/?mode=json | jq ".[] | select(.version | startswith(\"go${CGO_VERSION}\")).version" | tr -d "\"") && \N
49+
wget -q https://go.dev/dl/$LATEST_GO.linux-amd64.tar.gz -O - | tar -xz -C /usr/local && \N
50+
cp -a /etc/OpenCL /usr/lib64/libocloc.so /usr/lib64/libze_intel_gpu.* /usr/lib64/libze_loader.* /usr/lib64/libigdgmm.* /runtime/ && \N
51+
mkdir /runtime/licenses/ && cd /usr/share/licenses/ && cp -a level-zero intel-gmmlib intel-level-zero-gpu intel-ocloc /runtime/licenses/; \N
52+
fi
53+
54+
ARG EP=_ENTRYPOINT_
55+
ARG CMD
56+
57+
WORKDIR ${DIR}
58+
COPY . .
59+
60+
RUN export PATH=$PATH:/usr/local/go/bin/ && cd cmd/${CMD} && \N
61+
GO111MODULE=on CGO_ENABLED=1 go install $CGOFLAGS --gcflags="$GCFLAGS" --asmflags="$ASMFLAGS" --ldflags="$LDFLAGS"
62+
RUN [ $ROCKYLINUX -eq 0 ] && install -D /go/bin/${CMD} /install_root${EP} || install -D /root/go/bin/${CMD} /install_root${EP}
63+
64+
#include "default_licenses.docker"
65+
66+
FROM ${FINAL_BASE_DYN}
67+
68+
ARG CMD
69+
ARG ROCKYLINUX
70+
71+
COPY --from=builder /runtime /runtime
72+
73+
RUN if [ $ROCKYLINUX -eq 0 ]; then \N
74+
apt-get update && apt-get install --no-install-recommends -y ocl-icd-libopencl1 && \N
75+
rm /runtime/level-zero-devel_*.deb && \N
76+
cd /runtime && dpkg --ignore-depends=intel-igc-core,intel-igc-opencl -i *.deb && rm -rf /runtime && \N
77+
rm "/lib/x86_64-linux-gnu/libze_validation"* && rm "/lib/x86_64-linux-gnu/libze_tracing_layer"*; \N
78+
else \N
79+
cp -a /runtime//*.so* /usr/lib64/ && cp -a /runtime/OpenCL /etc/ && cp -a /runtime/licenses/* /usr/share/licenses/; \N
80+
fi
81+
82+
#include "default_end.docker"
83+
#include "default_labels.docker"
84+
85+
LABEL name='intel-gpu-levelzero'
86+
LABEL summary='Intel® GPU levelzero for Kubernetes'
87+
LABEL description='The GPU levelzero container provides access to Levelzero API for the Intel GPU plugin'

0 commit comments

Comments
 (0)