Bump github.com/NVIDIA/go-nvlib to v0.5.0

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2024-05-28 13:28:28 +02:00
parent b407109bdf
commit ef57c07199
9 changed files with 17 additions and 25 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/NVIDIA/nvidia-container-toolkit
go 1.20 go 1.20
require ( require (
github.com/NVIDIA/go-nvlib v0.4.0 github.com/NVIDIA/go-nvlib v0.5.0
github.com/NVIDIA/go-nvml v0.12.0-6 github.com/NVIDIA/go-nvml v0.12.0-6
github.com/fsnotify/fsnotify v1.7.0 github.com/fsnotify/fsnotify v1.7.0
github.com/opencontainers/runtime-spec v1.2.0 github.com/opencontainers/runtime-spec v1.2.0

4
go.sum
View File

@ -1,5 +1,5 @@
github.com/NVIDIA/go-nvlib v0.4.0 h1:dvuqjjSamBODFuxttPg4H/xtNVQRZOSlwFtuNKybcGI= github.com/NVIDIA/go-nvlib v0.5.0 h1:951KGrfr+p3cs89alO9z/ZxPPWKxwht9tx9rxiADoLI=
github.com/NVIDIA/go-nvlib v0.4.0/go.mod h1:87z49ULPr4GWPSGfSIp3taU4XENRYN/enIg88MzcL4k= github.com/NVIDIA/go-nvlib v0.5.0/go.mod h1:87z49ULPr4GWPSGfSIp3taU4XENRYN/enIg88MzcL4k=
github.com/NVIDIA/go-nvml v0.12.0-6 h1:FJYc2KrpvX+VOC/8QQvMiQMmZ/nPMRpdJO/Ik4xfcr0= github.com/NVIDIA/go-nvml v0.12.0-6 h1:FJYc2KrpvX+VOC/8QQvMiQMmZ/nPMRpdJO/Ik4xfcr0=
github.com/NVIDIA/go-nvml v0.12.0-6/go.mod h1:8Llmj+1Rr+9VGGwZuRer5N/aCjxGuR5nPb/9ebBiIEQ= github.com/NVIDIA/go-nvml v0.12.0-6/go.mod h1:8Llmj+1Rr+9VGGwZuRer5N/aCjxGuR5nPb/9ebBiIEQ=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=

View File

@ -243,7 +243,7 @@ func TestUsesNVGPUModule(t *testing.T) {
t.Run(tc.description, func(t *testing.T) { t.Run(tc.description, func(t *testing.T) {
sut := additionalInfo{ sut := additionalInfo{
nvmllib: tc.nvmllib, nvmllib: tc.nvmllib,
devicelib: device.New(device.WithNvml(tc.nvmllib)), devicelib: device.New(tc.nvmllib),
} }
flag, _ := sut.UsesNVGPUModule() flag, _ := sut.UsesNVGPUModule()

View File

@ -99,7 +99,7 @@ func New(opts ...Option) (Interface, error) {
l.nvmllib = nvml.New() l.nvmllib = nvml.New()
} }
if l.devicelib == nil { if l.devicelib == nil {
l.devicelib = device.New(device.WithNvml(l.nvmllib)) l.devicelib = device.New(l.nvmllib)
} }
if l.infolib == nil { if l.infolib == nil {
l.infolib = info.New( l.infolib = info.New(

View File

@ -38,7 +38,7 @@ type Interface interface {
} }
type devicelib struct { type devicelib struct {
nvml nvml.Interface nvmllib nvml.Interface
skippedDevices map[string]struct{} skippedDevices map[string]struct{}
verifySymbols *bool verifySymbols *bool
migProfiles []MigProfile migProfiles []MigProfile
@ -47,14 +47,13 @@ type devicelib struct {
var _ Interface = &devicelib{} var _ Interface = &devicelib{}
// New creates a new instance of the 'device' interface. // New creates a new instance of the 'device' interface.
func New(opts ...Option) Interface { func New(nvmllib nvml.Interface, opts ...Option) Interface {
d := &devicelib{} d := &devicelib{
nvmllib: nvmllib,
}
for _, opt := range opts { for _, opt := range opts {
opt(d) opt(d)
} }
if d.nvml == nil {
d.nvml = nvml.New()
}
if d.verifySymbols == nil { if d.verifySymbols == nil {
verify := true verify := true
d.verifySymbols = &verify d.verifySymbols = &verify
@ -68,13 +67,6 @@ func New(opts ...Option) Interface {
return d return d
} }
// WithNvml provides an Option to set the NVML library used by the 'device' interface.
func WithNvml(nvml nvml.Interface) Option {
return func(d *devicelib) {
d.nvml = nvml
}
}
// WithVerifySymbols provides an option to toggle whether to verify select symbols exist in dynamic libraries before calling them. // WithVerifySymbols provides an option to toggle whether to verify select symbols exist in dynamic libraries before calling them.
func WithVerifySymbols(verify bool) Option { func WithVerifySymbols(verify bool) Option {
return func(d *devicelib) { return func(d *devicelib) {

View File

@ -51,7 +51,7 @@ func (d *devicelib) NewDevice(dev nvml.Device) (Device, error) {
// NewDeviceByUUID builds a new Device from a UUID. // NewDeviceByUUID builds a new Device from a UUID.
func (d *devicelib) NewDeviceByUUID(uuid string) (Device, error) { func (d *devicelib) NewDeviceByUUID(uuid string) (Device, error) {
dev, ret := d.nvml.DeviceGetHandleByUUID(uuid) dev, ret := d.nvmllib.DeviceGetHandleByUUID(uuid)
if ret != nvml.SUCCESS { if ret != nvml.SUCCESS {
return nil, fmt.Errorf("error getting device handle for uuid '%v': %v", uuid, ret) return nil, fmt.Errorf("error getting device handle for uuid '%v': %v", uuid, ret)
} }
@ -334,13 +334,13 @@ func (d *device) isSkipped() (bool, error) {
// VisitDevices visits each top-level device and invokes a callback function for it. // VisitDevices visits each top-level device and invokes a callback function for it.
func (d *devicelib) VisitDevices(visit func(int, Device) error) error { func (d *devicelib) VisitDevices(visit func(int, Device) error) error {
count, ret := d.nvml.DeviceGetCount() count, ret := d.nvmllib.DeviceGetCount()
if ret != nvml.SUCCESS { if ret != nvml.SUCCESS {
return fmt.Errorf("error getting device count: %v", ret) return fmt.Errorf("error getting device count: %v", ret)
} }
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
device, ret := d.nvml.DeviceGetHandleByIndex(i) device, ret := d.nvmllib.DeviceGetHandleByIndex(i)
if ret != nvml.SUCCESS { if ret != nvml.SUCCESS {
return fmt.Errorf("error getting device handle for index '%v': %v", i, ret) return fmt.Errorf("error getting device handle for index '%v': %v", i, ret)
} }
@ -469,5 +469,5 @@ func (d *devicelib) hasSymbol(symbol string) bool {
return true return true
} }
return d.nvml.Extensions().LookupSymbol(symbol) == nil return d.nvmllib.Extensions().LookupSymbol(symbol) == nil
} }

View File

@ -50,7 +50,7 @@ func (d *devicelib) NewMigDevice(handle nvml.Device) (MigDevice, error) {
// NewMigDeviceByUUID builds a new MigDevice from a UUID. // NewMigDeviceByUUID builds a new MigDevice from a UUID.
func (d *devicelib) NewMigDeviceByUUID(uuid string) (MigDevice, error) { func (d *devicelib) NewMigDeviceByUUID(uuid string) (MigDevice, error) {
dev, ret := d.nvml.DeviceGetHandleByUUID(uuid) dev, ret := d.nvmllib.DeviceGetHandleByUUID(uuid)
if ret != nvml.SUCCESS { if ret != nvml.SUCCESS {
return nil, fmt.Errorf("error getting device handle for uuid '%v': %v", uuid, ret) return nil, fmt.Errorf("error getting device handle for uuid '%v': %v", uuid, ret)
} }

View File

@ -55,7 +55,7 @@ func New(opts ...Option) Interface {
) )
} }
if o.devicelib == nil { if o.devicelib == nil {
o.devicelib = device.New(device.WithNvml(o.nvmllib)) o.devicelib = device.New(o.nvmllib)
} }
if o.platform == "" { if o.platform == "" {
o.platform = PlatformAuto o.platform = PlatformAuto

2
vendor/modules.txt vendored
View File

@ -1,4 +1,4 @@
# github.com/NVIDIA/go-nvlib v0.4.0 # github.com/NVIDIA/go-nvlib v0.5.0
## explicit; go 1.20 ## explicit; go 1.20
github.com/NVIDIA/go-nvlib/pkg/nvlib/device github.com/NVIDIA/go-nvlib/pkg/nvlib/device
github.com/NVIDIA/go-nvlib/pkg/nvlib/info github.com/NVIDIA/go-nvlib/pkg/nvlib/info