-
Notifications
You must be signed in to change notification settings - Fork 173
feat(nvidia-fabricmanager): support Blackwell baseboards (DGX/HGX B100/B200/B300) #717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
npdgm
wants to merge
1
commit into
siderolabs:main
Choose a base branch
from
npdgm:feat/nvidia-nvlsm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
nvidia-gpu/nvidia-fabricmanager/nvidia-fabricmanager-gcc-runtime/pkg.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: nvidia-fabricmanager-gcc-runtime | ||
variant: scratch | ||
dependencies: | ||
- image: cgr.dev/chainguard/wolfi-base@{{ .WOLFI_BASE_REF }} | ||
steps: | ||
- install: | ||
- | | ||
mkdir -p /rootfs/usr/local/lib/containers/nvidia-fabricmanager/opt/nvidia/nvlsm/lib | ||
cp /usr/lib/libgcc_s.so.1 /rootfs/usr/local/lib/containers/nvidia-fabricmanager/opt/nvidia/nvlsm/lib/ | ||
finalize: | ||
- from: /rootfs | ||
to: /rootfs |
1 change: 1 addition & 0 deletions
1
nvidia-gpu/nvidia-fabricmanager/nvidia-fabricmanager-gcc-runtime/vars.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
INTERNAL_PACKAGE: true |
5 changes: 5 additions & 0 deletions
5
nvidia-gpu/nvidia-fabricmanager/nvidia-fabricmanager-wrapper/go.mod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module nvidia-fabricmanager-wrapper | ||
|
||
go 1.23.0 | ||
|
||
require github.com/goaux/decowriter v1.0.0 |
2 changes: 2 additions & 0 deletions
2
nvidia-gpu/nvidia-fabricmanager/nvidia-fabricmanager-wrapper/go.sum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/goaux/decowriter v1.0.0 h1:f1mfBWGFIo3Upev3gswfGLQzQvC4SBVYi2ZAkNZsIaU= | ||
github.com/goaux/decowriter v1.0.0/go.mod h1:8GKUmiBlNCYxVHU2vlZoQHwLvYh7Iw1c7/tRekJbX7o= |
156 changes: 156 additions & 0 deletions
156
nvidia-gpu/nvidia-fabricmanager/nvidia-fabricmanager-wrapper/main.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
package main | ||
|
||
import ( | ||
"bufio" | ||
"context" | ||
"fmt" | ||
"log" | ||
"os" | ||
"os/exec" | ||
"os/signal" | ||
"path/filepath" | ||
"strings" | ||
"sync" | ||
"syscall" | ||
"time" | ||
|
||
"github.com/goaux/decowriter" | ||
) | ||
|
||
const ( | ||
// FabricManager | ||
fmCmdFile = "/usr/bin/nv-fabricmanager" | ||
fmConfigFile = "/usr/share/nvidia/nvswitch/fabricmanager.cfg" | ||
fmStopTimeout = 5 * time.Second | ||
|
||
// NVLSM | ||
smCmdFile = "/opt/nvidia/nvlsm/sbin/nvlsm" | ||
smConfigFile = "/usr/share/nvidia/nvlsm/nvlsm.conf" | ||
smPidFile = "/var/run/nvlsm.pid" | ||
smSocket = "/var/run/nvidia-fabricmanager/fm_sm_ipc.socket" | ||
smStopTimeout = 5 * time.Second | ||
smSocketWait = 15 * time.Second | ||
) | ||
|
||
func runCommand(ctx context.Context, wg *sync.WaitGroup, doneCb func(), waitDelay time.Duration, path string, arg ...string) { | ||
wg.Add(1) | ||
|
||
cmd := exec.CommandContext(ctx, path, arg...) | ||
cmd.WaitDelay = waitDelay | ||
cmd.Cancel = func() error { | ||
return cmd.Process.Signal(os.Interrupt) | ||
} | ||
|
||
// TODO line writer to log module | ||
name := filepath.Base(path) | ||
cmd.Stdout = decowriter.New(bufio.NewWriter(os.Stdout), []byte(name+": "), []byte{}) | ||
cmd.Stderr = decowriter.New(bufio.NewWriter(os.Stderr), []byte(name+": "), []byte{}) | ||
|
||
go func() { | ||
log.Printf("nvidia-fabricmanager-wrapper: running command: %s %s\n", path, strings.Join(arg, " ")) | ||
|
||
err := cmd.Run() | ||
if err == nil { | ||
log.Printf("nvidia-fabricmanager-wrapper: command %s [%d] completed successfully\n", path, cmd.Process.Pid) | ||
} else if exitErr, ok := err.(*exec.ExitError); ok { | ||
if exitErr.Exited() { | ||
log.Printf("nvidia-fabricmanager-wrapper: command %s [%d] exited with code %d\n", path, exitErr.Pid(), | ||
exitErr.ExitCode()) | ||
} else { | ||
log.Printf("nvidia-fabricmanager-wrapper: command %s [%d] was terminated\n", path, exitErr.Pid()) | ||
} | ||
} else { | ||
log.Printf("nvidia-fabricmanager-wrapper: failed to run command %s: %v\n", path, err) | ||
} | ||
|
||
wg.Done() | ||
doneCb() | ||
}() | ||
} | ||
|
||
func waitForFile(ctx context.Context, filepath string, timeout time.Duration) error { | ||
timer := time.NewTimer(timeout) | ||
defer timer.Stop() | ||
|
||
for { | ||
select { | ||
case <-ctx.Done(): | ||
return fmt.Errorf("parent context canceled: %w", ctx.Err()) | ||
case <-timer.C: | ||
return fmt.Errorf("timeout waiting for file") | ||
default: | ||
if _, err := os.Stat(filepath); err == nil { | ||
return nil | ||
} | ||
time.Sleep(100 * time.Millisecond) | ||
} | ||
} | ||
} | ||
|
||
func main() { | ||
var cmdWg sync.WaitGroup | ||
|
||
signal.Ignore(syscall.SIGHUP) | ||
|
||
runCtx, gracefulShutdown := context.WithCancel(context.Background()) | ||
|
||
signalsChan := make(chan os.Signal, 1) | ||
signal.Notify(signalsChan, os.Interrupt) | ||
signal.Notify(signalsChan, syscall.SIGTERM) | ||
|
||
go func() { | ||
received := <-signalsChan | ||
signal.Stop(signalsChan) | ||
log.Printf("nvidia-fabricmanager-wrapper: received signal '%s', initiating a graceful shutdown\n", received.String()) | ||
gracefulShutdown() | ||
}() | ||
|
||
nvswitchPorts := findNvswitchMgmtPorts() | ||
for _, port := range nvswitchPorts { | ||
log.Printf("nvidia-fabricmanager-wrapper: found NVSwitch LPF: device=%s guid=0x%x\n", port.IBDevice, port.PortGUID) | ||
} | ||
|
||
fmSmMgmtPortGUID := "" | ||
if len(nvswitchPorts) > 0 { | ||
fmSmMgmtPortGUID = fmt.Sprintf("0x%x", nvswitchPorts[0].PortGUID) | ||
log.Printf("nvidia-fabricmanager-wrapper: using NVSwitch management port GUID: %s\n", fmSmMgmtPortGUID) | ||
} else { | ||
log.Println("nvidia-fabricmanager-wrapper: No InfiniBand NVSwitch detected. On Blackwell HGX baseboards and newer", | ||
"with NVLink 5.0+, please load kernel module 'ib_umad' for NVLSM to run along FabricManager. Otherwise it will", | ||
"fail to start with error NV_WARN_NOTHING_TO_DO, and GPU workloads will report CUDA_ERROR_SYSTEM_NOT_READY.") | ||
} | ||
|
||
if fmSmMgmtPortGUID != "" { | ||
if err := os.Mkdir(filepath.Dir(smSocket), 0755); err != nil { | ||
log.Printf("nvidia-fabricmanager-wrapper: error creating socket directory: %v\n", err) | ||
} | ||
|
||
runCommand(runCtx, &cmdWg, gracefulShutdown, smStopTimeout, smCmdFile, "--config", smConfigFile, | ||
"--guid", fmSmMgmtPortGUID, "--pid_file", smPidFile, "--log_file", "stdout") | ||
|
||
// vendor startup script waits for 5 seconds for NVLSM socket to be available before starting FM | ||
// let's wait for the actual GRPC socket to be created by the plugin | ||
log.Println("nvidia-fabricmanager-wrapper: waiting for socket creation at", smSocket) | ||
err := waitForFile(runCtx, smSocket, smSocketWait) | ||
if err != nil { | ||
log.Printf("nvidia-fabricmanager-wrapper: error waiting for socket: %v\n", err) | ||
} else { | ||
log.Println("nvidia-fabricmanager-wrapper: socket found at", smSocket) | ||
} | ||
// for safety | ||
time.Sleep(time.Second) | ||
dsseng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
fmCmdArgs := []string{"--config", fmConfigFile} | ||
if fmSmMgmtPortGUID != "" { | ||
fmCmdArgs = append(fmCmdArgs, "--fm-sm-mgmt-port-guid", fmSmMgmtPortGUID) | ||
} | ||
runCommand(runCtx, &cmdWg, gracefulShutdown, fmStopTimeout, fmCmdFile, fmCmdArgs...) | ||
|
||
log.Println("nvidia-fabricmanager-wrapper: initialization completed") | ||
cmdWg.Wait() | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we don't need to do this hack anymore? since this stage doesn't seem to use anything from wolfi anymore?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Sorry I had it fixed in
production
but notlts
. Both are the same now, except for vars.So the base stage is back to
/
, and Wolfi is pulled to/wolfi-base
. We still need Wolfi because of thelibgcc_s.so.1
file we copy to the extension rootfs, for NVLSM. No package is installed so that file is locked down byWOLFI_BASE_REF
. Anyway, GCC's runtime library is quite small and portable, we could pick one from any distro or version and that would work.