MCPcopy Create free account
hub / github.com/NVIDIA/gpu-operator / validateDriverContainer

Function validateDriverContainer

cmd/nvidia-validator/main.go:765–808  ·  view source on GitHub ↗
(silent bool, driverManagedByOperator bool)

Source from the content-addressed store, hash-verified

763}
764
765func validateDriverContainer(silent bool, driverManagedByOperator bool) error {
766 if driverManagedByOperator {
767 log.Infof("Driver is not pre-installed on the host and is managed by GPU Operator. Checking driver container status.")
768 if err := assertDriverContainerReady(silent); err != nil {
769 return fmt.Errorf("error checking driver container status: %w", err)
770 }
771 }
772
773 driverRoot := root(driverInstallDirCtrPathFlag)
774
775 validateDriver := func(silent bool) error {
776 driverLibraryPath, err := driverRoot.getDriverLibraryPath()
777 if err != nil {
778 return fmt.Errorf("failed to locate driver libraries: %w", err)
779 }
780
781 nvidiaSMIPath, err := driverRoot.getNvidiaSMIPath()
782 if err != nil {
783 return fmt.Errorf("failed to locate nvidia-smi: %w", err)
784 }
785 cmd := exec.Command(nvidiaSMIPath)
786 // In order for nvidia-smi to run, we need to update LD_PRELOAD to include the path to libnvidia-ml.so.1.
787 cmd.Env = setEnvVar(os.Environ(), "LD_PRELOAD", prependPathListEnvvar("LD_PRELOAD", driverLibraryPath))
788 if !silent {
789 cmd.Stdout = os.Stdout
790 cmd.Stderr = os.Stderr
791 }
792 return cmd.Run()
793 }
794
795 for {
796 log.Info("Attempting to validate a driver container installation")
797 err := validateDriver(silent)
798 if err != nil {
799 if !withWaitFlag {
800 return fmt.Errorf("error validating driver: %w", err)
801 }
802 log.Warningf("failed to validate the driver, retrying after %d seconds\n", sleepIntervalSecondsFlag)
803 time.Sleep(time.Duration(sleepIntervalSecondsFlag) * time.Second)
804 continue
805 }
806 return nil
807 }
808}
809
810func (d *Driver) runValidation(silent bool) (driverInfo, error) {
811 err := validateHostDriver(silent)

Callers 1

runValidationMethod · 0.85

Calls 7

rootTypeAlias · 0.85
setEnvVarFunction · 0.85
prependPathListEnvvarFunction · 0.85
getDriverLibraryPathMethod · 0.80
getNvidiaSMIPathMethod · 0.80
RunMethod · 0.80

Tested by

no test coverage detected