mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
remove runtime wrapper driver detection
This will be handled by the runtime itself. Signed-off-by: Jean-Francois Roy <jeroy@nvidia.com>
This commit is contained in:
parent
0c1e76a221
commit
d9c52ecd4e
@ -22,8 +22,6 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
@ -34,18 +32,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to get executable: %v", err)
|
log.Fatalf("failed to get executable: %v", err)
|
||||||
}
|
}
|
||||||
if isRuntimeWrapper(program) && !isNvidiaModuleLoaded() {
|
|
||||||
log.Println("nvidia driver modules are not yet loaded, invoking runc directly")
|
|
||||||
program, err := exec.LookPath("runc")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("failed to find runc: %v", err)
|
|
||||||
}
|
|
||||||
argv := []string{"runc"}
|
|
||||||
argv = append(argv, os.Args[1:]...)
|
|
||||||
if err := unix.Exec(program, argv, os.Environ()); err != nil {
|
|
||||||
log.Fatalf("failed to exec %s: %v", program, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argv := makeArgv(program)
|
argv := makeArgv(program)
|
||||||
envv := makeEnvv(program)
|
envv := makeEnvv(program)
|
||||||
if err := unix.Exec(program+".real", argv, envv); err != nil {
|
if err := unix.Exec(program+".real", argv, envv); err != nil {
|
||||||
@ -54,17 +40,6 @@ func main() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func isRuntimeWrapper(program string) bool {
|
|
||||||
return filepath.Base(program) == "nvidia-container-runtime" ||
|
|
||||||
filepath.Base(program) == "nvidia-container-runtime.cdi" ||
|
|
||||||
filepath.Base(program) == "nvidia-container-runtime.legacy"
|
|
||||||
}
|
|
||||||
|
|
||||||
func isNvidiaModuleLoaded() bool {
|
|
||||||
_, err := os.Stat("/proc/driver/nvidia/version")
|
|
||||||
return err == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeArgv(program string) []string {
|
func makeArgv(program string) []string {
|
||||||
argv := []string{os.Args[0] + ".real"}
|
argv := []string{os.Args[0] + ".real"}
|
||||||
f, err := os.Open(program + ".argv")
|
f, err := os.Open(program + ".argv")
|
||||||
|
Loading…
Reference in New Issue
Block a user