-
Notifications
You must be signed in to change notification settings - Fork 49
fix issue79: Add support for golang 1.24 and dgx-spark GB10 GPU #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,9 +20,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| wget && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| ENV GOLANG_VERSION 1.19.3 | ||
| RUN wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-amd64.tar.gz \ | ||
| | tar -C /usr/local -xz | ||
| ARG TARGETARCH | ||
| RUN wget -qO- https://storage.googleapis.com/golang/go1.23.7.linux-${TARGETARCH}.tar.gz | tar -C /usr/local -zx | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better maintainability, it's recommended to define the Go version as a build argument ( |
||
| ENV GOPATH /go | ||
| ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| module volcano.sh/k8s-device-plugin | ||
|
|
||
| go 1.14 | ||
| go 1.23 | ||
|
|
||
| replace ( | ||
| k8s.io/api => k8s.io/api v0.18.2 | ||
|
|
@@ -28,13 +28,11 @@ replace ( | |
| ) | ||
|
|
||
| require ( | ||
| github.com/NVIDIA/gpu-monitoring-tools v0.0.0-20200421213100-de959f43b55a | ||
| github.com/NVIDIA/go-nvml v0.12.4-1 | ||
| github.com/fsnotify/fsnotify v1.4.9 | ||
| github.com/mitchellh/gox v1.0.1 // indirect | ||
| github.com/prometheus/common v0.4.1 | ||
| github.com/stretchr/testify v1.5.1 | ||
| github.com/stretchr/testify v1.9.0 | ||
| github.com/urfave/cli/v2 v2.4.0 | ||
| golang.org/x/net v0.0.0-20200421231249-e086a090c8fd // indirect | ||
| google.golang.org/grpc v1.29.0 | ||
| k8s.io/api v0.18.2 | ||
| k8s.io/apimachinery v0.18.2 | ||
|
|
@@ -45,3 +43,39 @@ require ( | |
| k8s.io/kubernetes v1.18.2 | ||
| sigs.k8s.io/yaml v1.2.0 | ||
| ) | ||
|
|
||
| require ( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not merge the depend together |
||
| github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect | ||
| github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect | ||
| github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect | ||
| github.com/davecgh/go-spew v1.1.1 // indirect | ||
| github.com/go-logr/logr v1.2.0 // indirect | ||
| github.com/gogo/protobuf v1.3.1 // indirect | ||
| github.com/golang/protobuf v1.3.3 // indirect | ||
| github.com/google/gofuzz v1.1.0 // indirect | ||
| github.com/googleapis/gnostic v0.1.0 // indirect | ||
| github.com/imdario/mergo v0.3.5 // indirect | ||
| github.com/json-iterator/go v1.1.8 // indirect | ||
| github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect | ||
| github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
| github.com/modern-go/reflect2 v1.0.1 // indirect | ||
| github.com/pmezard/go-difflib v1.0.0 // indirect | ||
| github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
| github.com/sirupsen/logrus v1.4.2 // indirect | ||
| github.com/spf13/pflag v1.0.5 // indirect | ||
| golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 // indirect | ||
| golang.org/x/net v0.0.0-20200421231249-e086a090c8fd // indirect | ||
| golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect | ||
| golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 // indirect | ||
| golang.org/x/text v0.3.2 // indirect | ||
| golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect | ||
| google.golang.org/appengine v1.5.0 // indirect | ||
| google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 // indirect | ||
| gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect | ||
| gopkg.in/inf.v0 v0.9.1 // indirect | ||
| gopkg.in/yaml.v2 v2.2.8 // indirect | ||
| gopkg.in/yaml.v3 v3.0.1 // indirect | ||
| k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c // indirect | ||
| k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 // indirect | ||
| sigs.k8s.io/structured-merge-diff/v3 v3.0.0 // indirect | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| Copyright 2025 The Volcano Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package nvidia | ||
|
|
||
| // int8Slice wraps an []int8 with more functions. | ||
| type int8Slice []int8 | ||
|
|
||
| // String turns a nil terminated int8Slice into a string | ||
| func (s int8Slice) String() string { | ||
| var b []byte | ||
| for _, c := range s { | ||
| if c == 0 { | ||
| break | ||
| } | ||
| b = append(b, byte(c)) | ||
| } | ||
| return string(b) | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||||||||||
| package nvidia | ||||||||||||||
|
|
||||||||||||||
| import ( | ||||||||||||||
| "bytes" | ||||||||||||||
| "fmt" | ||||||||||||||
| "os/exec" | ||||||||||||||
| "strconv" | ||||||||||||||
| "strings" | ||||||||||||||
|
|
||||||||||||||
| "k8s.io/klog/v2" | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
| // GetHostMemory runs `free -b` and parses total/used/free (in bytes), | ||||||||||||||
| // supporting both English and localized (e.g. Chinese) output. | ||||||||||||||
| func GetHostMemory() (uint64, error) { | ||||||||||||||
| cmd := exec.Command("free", "-b") | ||||||||||||||
| var out bytes.Buffer | ||||||||||||||
| cmd.Stdout = &out | ||||||||||||||
| cmd.Stderr = &out | ||||||||||||||
|
|
||||||||||||||
| if err := cmd.Run(); err != nil { | ||||||||||||||
| return 0, fmt.Errorf("failed to run 'free -b': %v, output: %s", err, out.String()) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| lines := strings.Split(strings.TrimSpace(out.String()), "\n") | ||||||||||||||
| if len(lines) < 2 { | ||||||||||||||
| return 0, fmt.Errorf("unexpected 'free' output: %s", out.String()) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // find the first line that looks like data (numeric second field) | ||||||||||||||
| for _, line := range lines { | ||||||||||||||
| fields := strings.Fields(line) | ||||||||||||||
| if len(fields) < 3 { | ||||||||||||||
| continue | ||||||||||||||
| } | ||||||||||||||
| // skip header lines (contain non-digit in second field) | ||||||||||||||
| if _, err := strconv.ParseUint(strings.ReplaceAll(fields[1], ",", ""), 10, 64); err != nil { | ||||||||||||||
| continue | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // found the data line | ||||||||||||||
| total, err1 := strconv.ParseUint(fields[1], 10, 64) | ||||||||||||||
| used, err2 := strconv.ParseUint(fields[2], 10, 64) | ||||||||||||||
| free, err3 := strconv.ParseUint(fields[3], 10, 64) | ||||||||||||||
|
Comment on lines
+42
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check on line 37 correctly handles commas in the memory value by using
Suggested change
|
||||||||||||||
| if err1 != nil || err2 != nil || err3 != nil { | ||||||||||||||
| return 0, fmt.Errorf("parse error: %v %v %v", err1, err2, err3) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| klog.Infof("get system memory total: %dGB, used: %dGB, free: %dGB", total/1024/1024/1024, used/1024/1024/1024, free/1024/1024/1024) | ||||||||||||||
| return total, nil | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| return 0, fmt.Errorf("no memory data line found in 'free' output") | ||||||||||||||
| } | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better maintainability, it's recommended to define the Go version as a build argument (
ARG) instead of hardcoding it. Please addARG GOLANG_VERSION=1.23.7before this line and then use${GOLANG_VERSION}here.