Skip to content

Commit 186dee8

Browse files
Merge pull request #1410 from jmencak/4.21-nvidia-smi-wrapper
NO-JIRA: Fix support for nvidia-smi
2 parents 782cd43 + 7c7ab4f commit 186dee8

File tree

5 files changed

+8
-112
lines changed

5 files changed

+8
-112
lines changed

assets/bin/nvidia-smi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# This is a wrapper around /run/nvidia/driver/usr/bin/nvidia-smi binary,
4+
# which is populated by the NVIDIA GPU Operator on OpenShift. The
5+
# binary will not exist unless the NVIDIA GPU Operator on OpenShift is
6+
# installed. The primary use case is to set NVIDIA GPU frequencies and
7+
# power caps via TuneD.
8+
chroot /run/nvidia/driver /usr/bin/nvidia-smi "$@"

pkg/tuned/controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ const (
8484
ocpTunedPersist = ocpTunedRunDir + "/persist"
8585
ocpTunedProvider = ocpTunedHome + "/provider"
8686
tunedPersistHome = "/var/lib/tuned"
87-
nvidiaDriverBinDir = "/run/nvidia/driver/usr/bin"
8887
// With the less aggressive rate limiter, retries will happen at 100ms*2^(retry_n-1):
8988
// 100ms, 200ms, 400ms, 800ms, 1.6s, 3.2s, 6.4s, 12.8s, 25.6s, 51.2s, 102.4s, 3.4m, 6.8m, 13.7m, 27.3m
9089
maxRetries = 15

pkg/tuned/run.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import (
2323
"time"
2424

2525
"k8s.io/klog/v2"
26-
27-
"github.com/openshift/cluster-node-tuning-operator/pkg/util"
2826
)
2927

3028
func TunedCreateCmdline(debug bool) (string, []string) {
@@ -101,10 +99,6 @@ func TunedRunNoDaemon(timeout time.Duration) error {
10199
ctx, cancel := context.WithTimeout(context.Background(), timeout)
102100
defer cancel()
103101

104-
if err := util.AddToPath(nvidiaDriverBinDir); err != nil {
105-
return err
106-
}
107-
108102
command, args := TunedCreateCmdline(false)
109103
if timeout > 0 {
110104
// CommandContext sets Cancel to call the Kill (SIGKILL) method on the command's Process.
@@ -126,10 +120,6 @@ func TunedRunNoDaemon(timeout time.Duration) error {
126120
func TunedRun(cmd *exec.Cmd, daemon *Daemon, onDaemonReload func()) error {
127121
klog.Infof("running cmd...")
128122

129-
if err := util.AddToPath(nvidiaDriverBinDir); err != nil {
130-
return err
131-
}
132-
133123
cmdReader, err := cmd.StderrPipe()
134124
if err != nil {
135125
return fmt.Errorf("error creating StderrPipe for tuned: %w", err)

pkg/util/os.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
package util
22

33
import (
4-
"fmt"
54
"os"
6-
"strings"
7-
)
8-
9-
const (
10-
pathSeparator = string(os.PathListSeparator)
115
)
126

137
// Delete a file if it exists. Returns nil if 'file' does not exist.
@@ -31,21 +25,3 @@ func Symlink(target, linkName string) error {
3125

3226
return nil
3327
}
34-
35-
// AddToPath adds 'path' to PATH environment variable unless it exists.
36-
// Returns nil unless os.Setenv() call fails.
37-
func AddToPath(path string) error {
38-
currentPath := os.Getenv("PATH")
39-
40-
paths := strings.Split(currentPath, pathSeparator)
41-
for _, p := range paths {
42-
if p == path {
43-
// 'path' already exists in PATH
44-
return nil
45-
}
46-
}
47-
48-
newPath := fmt.Sprintf("%s%s%s", currentPath, pathSeparator, path)
49-
50-
return os.Setenv("PATH", newPath)
51-
}

pkg/util/os_test.go

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)