From 5f2c450fad088279a9597525526b7bc7cb109948 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 3 Aug 2025 09:08:10 +0000 Subject: [PATCH] Bump github.com/NVIDIA/go-nvlib from 0.7.3 to 0.7.4 Bumps [github.com/NVIDIA/go-nvlib](https://github.com/NVIDIA/go-nvlib) from 0.7.3 to 0.7.4. - [Release notes](https://github.com/NVIDIA/go-nvlib/releases) - [Commits](https://github.com/NVIDIA/go-nvlib/compare/v0.7.3...v0.7.4) --- updated-dependencies: - dependency-name: github.com/NVIDIA/go-nvlib dependency-version: 0.7.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../go-nvlib/pkg/nvlib/device/mig_profile.go | 104 ++++++++++++++---- vendor/modules.txt | 2 +- 4 files changed, 86 insertions(+), 26 deletions(-) diff --git a/go.mod b/go.mod index 845a90c..12cdb9c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/NVIDIA/go-gpuallocator go 1.20 require ( - github.com/NVIDIA/go-nvlib v0.7.3 + github.com/NVIDIA/go-nvlib v0.7.4 github.com/NVIDIA/go-nvml v0.12.9-0 github.com/stretchr/testify v1.10.0 ) diff --git a/go.sum b/go.sum index f0e9e1d..5729a74 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/NVIDIA/go-nvlib v0.7.3 h1:kXc8PkWUlrwedSpM4fR8xT/DAq1NKy8HqhpgteFcGAw= -github.com/NVIDIA/go-nvlib v0.7.3/go.mod h1:i95Je7GinMy/+BDs++DAdbPmT2TubjNP8i8joC7DD7I= +github.com/NVIDIA/go-nvlib v0.7.4 h1:qnXK8qhm45YfxalhZ76XwKdAMmxz1GIgzE0e/Hhhshs= +github.com/NVIDIA/go-nvlib v0.7.4/go.mod h1:i95Je7GinMy/+BDs++DAdbPmT2TubjNP8i8joC7DD7I= github.com/NVIDIA/go-nvml v0.12.9-0 h1:e344UK8ZkeMeeLkdQtRhmXRxNf+u532LDZPGMtkdus0= github.com/NVIDIA/go-nvml v0.12.9-0/go.mod h1:+KNA7c7gIBH7SKSJ1ntlwkfN80zdx8ovl4hrK3LmPt4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go index c1f0190..6ab94ad 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go @@ -28,7 +28,9 @@ import ( const ( // AttributeMediaExtensions holds the string representation for the media extension MIG profile attribute. - AttributeMediaExtensions = "me" + AttributeMediaExtensions = "me" + AttributeMediaExtensionsAll = "me.all" + AttributeGraphics = "gfx" ) // MigProfile represents a specific MIG profile. @@ -46,6 +48,7 @@ type MigProfileInfo struct { G int GB int Attributes []string + NegAttributes []string GIProfileID int CIProfileID int CIEngProfileID int @@ -59,14 +62,21 @@ func (d *devicelib) NewMigProfile(giProfileID, ciProfileID, ciEngProfileID int, switch giProfileID { case nvml.GPU_INSTANCE_PROFILE_1_SLICE, nvml.GPU_INSTANCE_PROFILE_1_SLICE_REV1, - nvml.GPU_INSTANCE_PROFILE_1_SLICE_REV2: + nvml.GPU_INSTANCE_PROFILE_1_SLICE_REV2, + nvml.GPU_INSTANCE_PROFILE_1_SLICE_GFX, + nvml.GPU_INSTANCE_PROFILE_1_SLICE_NO_ME, + nvml.GPU_INSTANCE_PROFILE_1_SLICE_ALL_ME: giSlices = 1 case nvml.GPU_INSTANCE_PROFILE_2_SLICE, - nvml.GPU_INSTANCE_PROFILE_2_SLICE_REV1: + nvml.GPU_INSTANCE_PROFILE_2_SLICE_REV1, + nvml.GPU_INSTANCE_PROFILE_2_SLICE_GFX, + nvml.GPU_INSTANCE_PROFILE_2_SLICE_NO_ME, + nvml.GPU_INSTANCE_PROFILE_2_SLICE_ALL_ME: giSlices = 2 case nvml.GPU_INSTANCE_PROFILE_3_SLICE: giSlices = 3 - case nvml.GPU_INSTANCE_PROFILE_4_SLICE: + case nvml.GPU_INSTANCE_PROFILE_4_SLICE, + nvml.GPU_INSTANCE_PROFILE_4_SLICE_GFX: giSlices = 4 case nvml.GPU_INSTANCE_PROFILE_6_SLICE: giSlices = 6 @@ -104,6 +114,19 @@ func (d *devicelib) NewMigProfile(giProfileID, ciProfileID, ciEngProfileID int, case nvml.GPU_INSTANCE_PROFILE_1_SLICE_REV1, nvml.GPU_INSTANCE_PROFILE_2_SLICE_REV1: attrs = append(attrs, AttributeMediaExtensions) + case nvml.GPU_INSTANCE_PROFILE_1_SLICE_ALL_ME, + nvml.GPU_INSTANCE_PROFILE_2_SLICE_ALL_ME: + attrs = append(attrs, AttributeMediaExtensionsAll) + case nvml.GPU_INSTANCE_PROFILE_1_SLICE_GFX, + nvml.GPU_INSTANCE_PROFILE_2_SLICE_GFX, + nvml.GPU_INSTANCE_PROFILE_4_SLICE_GFX: + attrs = append(attrs, AttributeGraphics) + } + var negAttrs []string + switch giProfileID { + case nvml.GPU_INSTANCE_PROFILE_1_SLICE_NO_ME, + nvml.GPU_INSTANCE_PROFILE_2_SLICE_NO_ME: + negAttrs = append(negAttrs, AttributeMediaExtensions) } p := &MigProfileInfo{ @@ -111,6 +134,7 @@ func (d *devicelib) NewMigProfile(giProfileID, ciProfileID, ciEngProfileID int, G: giSlices, GB: int(getMigMemorySizeGB(deviceMemorySizeBytes, migMemorySizeMB)), Attributes: attrs, + NegAttributes: negAttrs, GIProfileID: giProfileID, CIProfileID: ciProfileID, CIEngProfileID: ciEngProfileID, @@ -121,7 +145,7 @@ func (d *devicelib) NewMigProfile(giProfileID, ciProfileID, ciEngProfileID int, // AssertValidMigProfileFormat checks if the string is in the proper format to represent a MIG profile. func (d *devicelib) AssertValidMigProfileFormat(profile string) error { - _, _, _, _, err := parseMigProfile(profile) + _, err := parseMigProfile(profile) return err } @@ -147,6 +171,9 @@ func (p MigProfileInfo) String() string { if len(p.Attributes) > 0 { suffix = "+" + strings.Join(p.Attributes, ",") } + if len(p.NegAttributes) > 0 { + suffix = "-" + strings.Join(p.NegAttributes, ",") + } if p.C == p.G { return fmt.Sprintf("%dg.%dgb%s", p.G, p.GB, suffix) } @@ -184,59 +211,89 @@ func (p MigProfileInfo) Equals(other MigProfile) bool { // Matches checks if a MigProfile matches the string passed in. func (p MigProfileInfo) Matches(profile string) bool { - c, g, gb, attrs, err := parseMigProfile(profile) + migProfileInfo, err := parseMigProfile(profile) if err != nil { return false } - if c != p.C { + if migProfileInfo.C != p.C { + return false + } + if migProfileInfo.G != p.G { return false } - if g != p.G { + if migProfileInfo.GB != p.GB { return false } - if gb != p.GB { + if !matchAttributes(migProfileInfo.Attributes, p.Attributes) { return false } - if len(attrs) != len(p.Attributes) { + if !matchAttributes(migProfileInfo.NegAttributes, p.NegAttributes) { return false } - sort.Strings(attrs) - sort.Strings(p.Attributes) - for i, a := range p.Attributes { - if a != attrs[i] { + return true +} + +func matchAttributes(attrs1, attrs2 []string) bool { + if len(attrs1) != len(attrs2) { + return false + } + sort.Strings(attrs1) + sort.Strings(attrs2) + for i, a := range attrs2 { + if a != attrs1[i] { return false } } return true } -func parseMigProfile(profile string) (int, int, int, []string, error) { +func parseMigProfile(profile string) (*MigProfileInfo, error) { // If we are handed the empty string, we cannot parse it. if profile == "" { - return -1, -1, -1, nil, fmt.Errorf("profile is the empty string") + return nil, fmt.Errorf("profile is the empty string") } - // Split by + to separate out attributes. + // Split by +/- to separate out attributes. split := strings.SplitN(profile, "+", 2) + negsplit := strings.SplitN(profile, "-", 2) + // Make sure we don't get both positive and negative attributes. + if len(split) == 2 && len(negsplit) == 2 { + return nil, fmt.Errorf("profile '%v' contains both '+/-' attributes", profile) + } + + if len(split) == 1 { + split = negsplit + } // Check to make sure the c, g, and gb values match. c, g, gb, err := parseMigProfileFields(split[0]) if err != nil { - return -1, -1, -1, nil, fmt.Errorf("cannot parse fields of '%v': %v", profile, err) + return nil, fmt.Errorf("cannot parse fields of '%v': %v", profile, err) } + migProfileInfo := &MigProfileInfo{ + C: c, + G: g, + GB: gb, + } // If we have no attributes we are done. if len(split) == 1 { - return c, g, gb, nil, nil + return migProfileInfo, nil } // Make sure we have the same set of attributes. attrs, err := parseMigProfileAttributes(split[1]) if err != nil { - return -1, -1, -1, nil, fmt.Errorf("cannot parse attributes of '%v': %v", profile, err) + return nil, fmt.Errorf("cannot parse attributes of '%v': %v", profile, err) + } + + if len(negsplit) == 2 { + migProfileInfo.NegAttributes = attrs + return migProfileInfo, nil } - return c, g, gb, attrs, nil + migProfileInfo.Attributes = attrs + return migProfileInfo, nil } func parseMigProfileField(s string, field string) (int, error) { @@ -310,8 +367,11 @@ func parseMigProfileAttributes(s string) ([]string, error) { if a[0] >= '0' && a[0] <= '9' { return nil, fmt.Errorf("attribute begins with a number") } + if a[0] == '.' || a[len(a)-1] == '.' { + return nil, fmt.Errorf("attribute begins/ends with a dot") + } for _, c := range a { - if (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9') { + if (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9') && c != '.' { return nil, fmt.Errorf("non alpha-numeric character or digit in attribute") } } diff --git a/vendor/modules.txt b/vendor/modules.txt index b4bf369..f1cf1dc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/NVIDIA/go-nvlib v0.7.3 +# github.com/NVIDIA/go-nvlib v0.7.4 ## explicit; go 1.20 github.com/NVIDIA/go-nvlib/pkg/nvlib/device # github.com/NVIDIA/go-nvml v0.12.9-0