Skip to content

Commit

Permalink
Set LD_PRELOAD to include libnvidia-ml.so.1
Browse files Browse the repository at this point in the history
This change sets LD_PRLOAD to include the full path to libnvidia-ml.so.1.
This allows nvidia-smi in the container to locate this library without
causing conflicts with other libraries in the driver-root.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
  • Loading branch information
elezar committed Nov 1, 2023
1 parent c3662ef commit c53420e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/nvidia-dra-plugin/nvlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type deviceLib struct {
}

func newDeviceLib(driverRoot root) (*deviceLib, error) {
libraryPath, err := driverRoot.getDriverLibraryPath()
driverLibraryPath, err := driverRoot.getDriverLibraryPath()
if err != nil {
return nil, fmt.Errorf("failed to locate driver libraries: %w", err)
}
Expand All @@ -47,15 +47,15 @@ func newDeviceLib(driverRoot root) (*deviceLib, error) {
}

// In order for nvidia-smi to run, we need to set the PATH to the parent of
// the nvidia-smi executable and update the LD_LIBRARY_PATH to be able to
// locate libnvidia-ml.so.1
updatePathListEnvvar("LD_LIBRARY_PATH", filepath.Dir(libraryPath))
// the nvidia-smi executable and update LD_PRELOAD to include the path to
// libnvidia-ml.so.1
updatePathListEnvvar("LD_PRELOAD", driverLibraryPath)
updatePathListEnvvar("PATH", filepath.Dir(nvidiaSMIPath))

// We construct an NVML library specifying the path to libnvidia-ml.so.1 explicitly
// so that we don't have to rely on the library path.
// We construct an NVML library specifying the path to libnvidia-ml.so.1
// explicitly so that we don't have to rely on the library path.
nvmllib := nvml.New(
nvml.WithLibraryPath(libraryPath),
nvml.WithLibraryPath(driverLibraryPath),
)
d := deviceLib{
Interface: nvdev.New(nvdev.WithNvml(nvmllib)),
Expand Down

0 comments on commit c53420e

Please sign in to comment.