Skip to content

Commit 2571308

Browse files
committed
init
Signed-off-by: zoyopei <[email protected]>
0 parents  commit 2571308

File tree

12 files changed

+1285
-0
lines changed

12 files changed

+1285
-0
lines changed

.github/workflows/go.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: CI
5+
6+
on:
7+
push:
8+
branches: [ "master", "main" ]
9+
tags:
10+
- v[0-9]+.[0-9]+.[0-9]+.[0-9]+
11+
- v[0-9]+.[0-9]+.[0-9]+
12+
- v[0-9]+.[0-9]+
13+
pull_request:
14+
branches: [ "master" ]
15+
16+
env:
17+
GO_VERSION: "1.22.5"
18+
19+
jobs:
20+
golangci:
21+
name: lint
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-go@v5
26+
with:
27+
go-version: ${{ env.GO_VERSION }}
28+
- name: golangci-lint
29+
uses: golangci/golangci-lint-action@v6
30+
with:
31+
version: v1.60
32+
33+
build:
34+
env:
35+
IMAGE_NAME: ${{ secrets.IMAGE_NAME || 'projecthami/ascend-device-plugin' }}
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Get branch names.
41+
id: branch-names
42+
uses: tj-actions/branch-names@v8
43+
44+
- name: Set up QEMU
45+
uses: docker/setup-qemu-action@v3
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
- name: Docker Login
51+
uses: docker/[email protected]
52+
with:
53+
username: ${{ secrets.DOCKERHUB_USER }}
54+
password: ${{ secrets.DOCKERHUB_TOKEN }}
55+
56+
- name: Build and push
57+
uses: docker/build-push-action@v6
58+
with:
59+
# platforms: linux/amd64,linux/arm64
60+
platforms: linux/arm64
61+
push: true
62+
build-args: |
63+
BASE_IMAGE=ubuntu:20.04
64+
GO_VERSION=${{ env.GO_VERSION }}
65+
VERSION=${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }}-${{ github.sha }}
66+
tags: ${{ env.IMAGE_NAME }}:${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }}

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ARG BASE_IMAGE=ubuntu:20.04
2+
3+
FROM $BASE_IMAGE AS build
4+
RUN apt update -y && apt install -y gcc make wget
5+
ARG GO_VERSION=1.22.5
6+
RUN wget https://golang.google.cn/dl/go$GO_VERSION.linux-arm64.tar.gz
7+
RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go$GO_VERSION.linux-arm64.tar.gz
8+
ENV PATH=/usr/local/go/bin:$PATH
9+
ARG GOPROXY
10+
ARG VERSION
11+
ADD . /build
12+
RUN --mount=type=cache,target=/go/pkg/mod \
13+
cd /build && make all
14+
15+
FROM $BASE_IMAGE
16+
ENV LD_LIBRARY_PATH /usr/local/Ascend/driver/lib64:/usr/local/Ascend/driver/lib64/driver:/usr/local/Ascend/driver/lib64/common
17+
COPY --from=build /build/ascend-device-plugin /usr/local/bin/ascend-device-plugin
18+
19+
ENTRYPOINT ["ascend-device-plugin"]

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
GO ?= go
2+
VERSION ?= unknown
3+
BUILDARGS ?= -ldflags '-s -w -X github.com/Project-HAMi/ascend-device-plugin/version.version=$(VERSION)'
4+
5+
all: ascend-device-plugin
6+
7+
tidy:
8+
$(GO) mod tidy
9+
10+
lint:
11+
$(GO) install github.com/golangci/golangci-lint/cmd/[email protected]
12+
golangci-lint run
13+
14+
ascend-device-plugin: tidy
15+
$(GO) build $(BUILDARGS) -o ./ascend-device-plugin
16+
17+
clean:
18+
rm -rf ./ascend-device-plugin
19+
20+
.PHONY: all clean

config.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
vnpus:
2+
- chipName: 910B
3+
commonWord: Ascend910A
4+
resourceName: huawei.com/Ascend910A
5+
resourceMemoryName: huawei.com/Ascend910A-memory
6+
memoryAllocatable: 32768
7+
memoryCapacity: 32768
8+
aiCore: 30
9+
templates:
10+
- name: vir02
11+
memory: 2184
12+
aiCore: 2
13+
- name: vir04
14+
memory: 4369
15+
aiCore: 4
16+
- name: vir08
17+
memory: 8738
18+
aiCore: 8
19+
- name: vir16
20+
memory: 17476
21+
aiCore: 16
22+
- chipName: 910B3
23+
commonWord: Ascend910B
24+
resourceName: huawei.com/Ascend910B
25+
resourceMemoryName: huawei.com/Ascend910B-memory
26+
memoryAllocatable: 65536
27+
memoryCapacity: 65536
28+
aiCore: 20
29+
aiCPU: 7
30+
templates:
31+
- name: vir05_1c_16g
32+
memory: 16384
33+
aiCore: 5
34+
aiCPU: 1
35+
- name: vir10_3c_32g
36+
memory: 32768
37+
aiCore: 10
38+
aiCPU: 3
39+
- chipName: 310P3
40+
commonWord: Ascend310P
41+
resourceName: huawei.com/Ascend310P
42+
resourceMemoryName: huawei.com/Ascend310P-memory
43+
memoryAllocatable: 21527
44+
memoryCapacity: 24576
45+
aiCore: 8
46+
aiCPU: 7
47+
templates:
48+
- name: vir01
49+
memory: 3072
50+
aiCore: 1
51+
aiCPU: 1
52+
- name: vir02
53+
memory: 6144
54+
aiCore: 2
55+
aiCPU: 2
56+
- name: vir04
57+
memory: 12288
58+
aiCore: 4
59+
aiCPU: 4

go.mod

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
module github.com/Project-HAMi/ascend-device-plugin
2+
3+
go 1.22.2
4+
5+
require (
6+
github.com/Project-HAMi/HAMi v0.0.0
7+
github.com/fsnotify/fsnotify v1.7.0
8+
google.golang.org/grpc v1.63.2
9+
huawei.com/npu-exporter/v6 v6.0.0-RC3.b001
10+
k8s.io/api v0.29.3
11+
k8s.io/apimachinery v0.29.3
12+
k8s.io/klog/v2 v2.120.1
13+
k8s.io/kubelet v0.29.3
14+
)
15+
16+
require (
17+
github.com/NVIDIA/k8s-device-plugin v0.15.0 // indirect
18+
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
19+
github.com/davecgh/go-spew v1.1.1 // indirect
20+
github.com/emicklei/go-restful/v3 v3.11.3 // indirect
21+
github.com/go-logr/logr v1.4.1 // indirect
22+
github.com/go-openapi/jsonpointer v0.20.2 // indirect
23+
github.com/go-openapi/jsonreference v0.20.4 // indirect
24+
github.com/go-openapi/swag v0.22.9 // indirect
25+
github.com/gogo/protobuf v1.3.2 // indirect
26+
github.com/golang/protobuf v1.5.4 // indirect
27+
github.com/google/gnostic-models v0.6.8 // indirect
28+
github.com/google/gofuzz v1.2.0 // indirect
29+
github.com/google/uuid v1.6.0 // indirect
30+
github.com/imdario/mergo v0.3.16 // indirect
31+
github.com/josharian/intern v1.0.0 // indirect
32+
github.com/json-iterator/go v1.1.12 // indirect
33+
github.com/mailru/easyjson v0.7.7 // indirect
34+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
35+
github.com/modern-go/reflect2 v1.0.2 // indirect
36+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
37+
github.com/opencontainers/runtime-spec v1.2.0 // indirect
38+
github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626 // indirect
39+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
40+
github.com/smartystreets/goconvey v1.7.2 // indirect
41+
github.com/spf13/pflag v1.0.5 // indirect
42+
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
43+
github.com/urfave/cli/v2 v2.27.1 // indirect
44+
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
45+
golang.org/x/mod v0.17.0 // indirect
46+
golang.org/x/net v0.26.0 // indirect
47+
golang.org/x/oauth2 v0.17.0 // indirect
48+
golang.org/x/sys v0.21.0 // indirect
49+
golang.org/x/term v0.21.0 // indirect
50+
golang.org/x/text v0.16.0 // indirect
51+
golang.org/x/time v0.5.0 // indirect
52+
google.golang.org/appengine v1.6.8 // indirect
53+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
54+
google.golang.org/protobuf v1.33.0 // indirect
55+
gopkg.in/inf.v0 v0.9.1 // indirect
56+
gopkg.in/yaml.v2 v2.4.0 // indirect
57+
gopkg.in/yaml.v3 v3.0.1 // indirect
58+
k8s.io/client-go v0.29.3 // indirect
59+
k8s.io/kube-openapi v0.0.0-20240227032403-f107216b40e2 // indirect
60+
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
61+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
62+
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
63+
sigs.k8s.io/yaml v1.4.0 // indirect
64+
tags.cncf.io/container-device-interface v0.7.1 // indirect
65+
tags.cncf.io/container-device-interface/specs-go v0.7.0 // indirect
66+
)
67+
68+
replace (
69+
github.com/Project-HAMi/HAMi v0.0.0 => github.com/zoyopei/HAMi v0.0.0-20240911093519-601839823f68
70+
huawei.com/npu-exporter/v6 => gitee.com/ascend/ascend-npu-exporter/v6 v6.0.0-RC2.b001
71+
)

0 commit comments

Comments
 (0)