mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Bump github.com/NVIDIA/go-nvlib
Bumps [github.com/NVIDIA/go-nvlib](https://github.com/NVIDIA/go-nvlib) from 0.0.0-20231115170030-b21432a353e1 to 0.2.0. - [Release notes](https://github.com/NVIDIA/go-nvlib/releases) - [Commits](https://github.com/NVIDIA/go-nvlib/commits/v0.2.0) --- updated-dependencies: - dependency-name: github.com/NVIDIA/go-nvlib dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
24
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/lib.go
generated
vendored
24
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/lib.go
generated
vendored
@@ -38,9 +38,10 @@ var errLibraryAlreadyLoaded = errors.New("library already loaded")
|
||||
// This includes a reference to the underlying DynamicLibrary
|
||||
type library struct {
|
||||
sync.Mutex
|
||||
path string
|
||||
flags int
|
||||
dl dynamicLibrary
|
||||
path string
|
||||
flags int
|
||||
refcount refcount
|
||||
dl dynamicLibrary
|
||||
}
|
||||
|
||||
// libnvml is a global instance of the nvml library.
|
||||
@@ -77,16 +78,17 @@ var newDynamicLibrary = func(path string, flags int) dynamicLibrary {
|
||||
|
||||
// load initializes the library and updates the versioned symbols.
|
||||
// Multiple calls to an already loaded library will return without error.
|
||||
func (l *library) load() error {
|
||||
func (l *library) load() (rerr error) {
|
||||
l.Lock()
|
||||
defer l.Unlock()
|
||||
if l.dl != nil {
|
||||
|
||||
defer func() { l.refcount.IncOnNoError(rerr) }()
|
||||
if l.refcount > 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
dl := newDynamicLibrary(l.path, l.flags)
|
||||
err := dl.Open()
|
||||
if err != nil {
|
||||
if err := dl.Open(); err != nil {
|
||||
return fmt.Errorf("error opening %s: %w", l.path, err)
|
||||
}
|
||||
|
||||
@@ -99,16 +101,16 @@ func (l *library) load() error {
|
||||
// close the underlying library and ensure that the global pointer to the
|
||||
// library is set to nil to ensure that subsequent calls to open will reinitialize it.
|
||||
// Multiple calls to an already closed nvml library will return without error.
|
||||
func (l *library) close() error {
|
||||
func (l *library) close() (rerr error) {
|
||||
l.Lock()
|
||||
defer l.Unlock()
|
||||
|
||||
if l.dl == nil {
|
||||
defer func() { l.refcount.DecOnNoError(rerr) }()
|
||||
if l.refcount != 1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := l.dl.Close()
|
||||
if err != nil {
|
||||
if err := l.dl.Close(); err != nil {
|
||||
return fmt.Errorf("error closing %s: %w", l.path, err)
|
||||
}
|
||||
|
||||
|
||||
31
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/refcount.go
generated
vendored
Normal file
31
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/refcount.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
# Copyright 2024 NVIDIA CORPORATION
|
||||
#
|
||||
# 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 nvml
|
||||
|
||||
type refcount int
|
||||
|
||||
func (r *refcount) IncOnNoError(err error) {
|
||||
if err == nil {
|
||||
(*r)++
|
||||
}
|
||||
}
|
||||
|
||||
func (r *refcount) DecOnNoError(err error) {
|
||||
if err == nil && (*r) > 0 {
|
||||
(*r)--
|
||||
}
|
||||
}
|
||||
77
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go
generated
vendored
77
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go
generated
vendored
@@ -14,7 +14,80 @@
|
||||
|
||||
package nvml
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// nvml.ErrorString()
|
||||
func ErrorString(Result Return) string {
|
||||
return nvmlErrorString(Result)
|
||||
func ErrorString(r Return) string {
|
||||
if err := GetLibrary().Lookup("nvmlErrorString"); err != nil {
|
||||
return fallbackErrorStringFunc(r)
|
||||
}
|
||||
return nvmlErrorString(r)
|
||||
}
|
||||
|
||||
// fallbackErrorStringFunc provides a basic nvmlErrorString implementation.
|
||||
// This allows the nvml.ErrorString function to be used even if the NVML library
|
||||
// is not loaded.
|
||||
var fallbackErrorStringFunc = func(r Return) string {
|
||||
switch r {
|
||||
case SUCCESS:
|
||||
return "SUCCESS"
|
||||
case ERROR_UNINITIALIZED:
|
||||
return "ERROR_UNINITIALIZED"
|
||||
case ERROR_INVALID_ARGUMENT:
|
||||
return "ERROR_INVALID_ARGUMENT"
|
||||
case ERROR_NOT_SUPPORTED:
|
||||
return "ERROR_NOT_SUPPORTED"
|
||||
case ERROR_NO_PERMISSION:
|
||||
return "ERROR_NO_PERMISSION"
|
||||
case ERROR_ALREADY_INITIALIZED:
|
||||
return "ERROR_ALREADY_INITIALIZED"
|
||||
case ERROR_NOT_FOUND:
|
||||
return "ERROR_NOT_FOUND"
|
||||
case ERROR_INSUFFICIENT_SIZE:
|
||||
return "ERROR_INSUFFICIENT_SIZE"
|
||||
case ERROR_INSUFFICIENT_POWER:
|
||||
return "ERROR_INSUFFICIENT_POWER"
|
||||
case ERROR_DRIVER_NOT_LOADED:
|
||||
return "ERROR_DRIVER_NOT_LOADED"
|
||||
case ERROR_TIMEOUT:
|
||||
return "ERROR_TIMEOUT"
|
||||
case ERROR_IRQ_ISSUE:
|
||||
return "ERROR_IRQ_ISSUE"
|
||||
case ERROR_LIBRARY_NOT_FOUND:
|
||||
return "ERROR_LIBRARY_NOT_FOUND"
|
||||
case ERROR_FUNCTION_NOT_FOUND:
|
||||
return "ERROR_FUNCTION_NOT_FOUND"
|
||||
case ERROR_CORRUPTED_INFOROM:
|
||||
return "ERROR_CORRUPTED_INFOROM"
|
||||
case ERROR_GPU_IS_LOST:
|
||||
return "ERROR_GPU_IS_LOST"
|
||||
case ERROR_RESET_REQUIRED:
|
||||
return "ERROR_RESET_REQUIRED"
|
||||
case ERROR_OPERATING_SYSTEM:
|
||||
return "ERROR_OPERATING_SYSTEM"
|
||||
case ERROR_LIB_RM_VERSION_MISMATCH:
|
||||
return "ERROR_LIB_RM_VERSION_MISMATCH"
|
||||
case ERROR_IN_USE:
|
||||
return "ERROR_IN_USE"
|
||||
case ERROR_MEMORY:
|
||||
return "ERROR_MEMORY"
|
||||
case ERROR_NO_DATA:
|
||||
return "ERROR_NO_DATA"
|
||||
case ERROR_VGPU_ECC_NOT_SUPPORTED:
|
||||
return "ERROR_VGPU_ECC_NOT_SUPPORTED"
|
||||
case ERROR_INSUFFICIENT_RESOURCES:
|
||||
return "ERROR_INSUFFICIENT_RESOURCES"
|
||||
case ERROR_FREQ_NOT_SUPPORTED:
|
||||
return "ERROR_FREQ_NOT_SUPPORTED"
|
||||
case ERROR_ARGUMENT_VERSION_MISMATCH:
|
||||
return "ERROR_ARGUMENT_VERSION_MISMATCH"
|
||||
case ERROR_DEPRECATED:
|
||||
return "ERROR_DEPRECATED"
|
||||
case ERROR_UNKNOWN:
|
||||
return "ERROR_UNKNOWN"
|
||||
default:
|
||||
return fmt.Sprintf("unknown return value: %d", r)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user