(silent bool, driverManagedByOperator bool)
| 763 | } |
| 764 | |
| 765 | func 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 | |
| 810 | func (d *Driver) runValidation(silent bool) (driverInfo, error) { |
| 811 | err := validateHostDriver(silent) |
no test coverage detected