mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-25 13:35:00 +00:00
Add HasNVML function to check if NVML is supported
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
9db5f9c9e8
commit
ad9ec1efae
@ -20,8 +20,25 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/NVIDIA/go-nvml/pkg/dl"
|
||||
)
|
||||
|
||||
// HasNVML returns true if NVML is detected on the sytems
|
||||
func HasNVML() (bool, string) {
|
||||
const (
|
||||
nvmlLibraryName = "libnvidia-ml.so.1"
|
||||
nvmlLibraryLoadFlags = dl.RTLD_LAZY
|
||||
)
|
||||
lib := dl.New(nvmlLibraryName, nvmlLibraryLoadFlags)
|
||||
if err := lib.Open(); err != nil {
|
||||
return false, fmt.Sprintf("could not load NVML: %v", err)
|
||||
}
|
||||
defer lib.Close()
|
||||
|
||||
return true, "found NVML library"
|
||||
}
|
||||
|
||||
// IsTegraSystem returns true if the system is detected as a Tegra-based system
|
||||
func IsTegraSystem() (bool, string) {
|
||||
const tegraReleaseFile = "/etc/nv_tegra_release"
|
Loading…
Reference in New Issue
Block a user