Fix cross-stream memory visibility race on DGX spark Blackwell (sm_121)#41
Open
willdzeng wants to merge 1 commit intonvidia-isaac:mainfrom
Open
Fix cross-stream memory visibility race on DGX spark Blackwell (sm_121)#41willdzeng wants to merge 1 commit intonvidia-isaac:mainfrom
willdzeng wants to merge 1 commit intonvidia-isaac:mainfrom
Conversation
On Blackwell GPUs (sm_121, e.g. GB10), CUDA memory writes from one stream are not guaranteed visible to kernels on another stream without explicit synchronization. This causes CUDA error 700 (illegal memory access) in multi-camera visual odometry after ~200 frames. Root cause: MonoSOFGPU::track() builds image pyramids and gradient pyramids on per-camera CUDA streams. These pyramids are later read by stereo pair tracking (LaunchTrackingPrimaryToSecondary) on different per-pair streams. On pre-Blackwell GPUs, the implicit memory ordering happened to work. On Blackwell, the stricter memory model exposes the missing synchronization. Fix: - Add cudaStreamSynchronize after pyramid+gradient build in MonoSOFGPU::track() to ensure data is visible to other streams - Add cudaDeviceSynchronize barriers in MultiSOFBase::trackNextFrame() before mono finish and stereo launch phases Tested on NVIDIA GB10 (aarch64, CUDA 13, sm_121) with 6-camera rig (3 stereo pairs, 8075 frames). Without fix: deterministic crash at frame ~209. With fix: completes all frames without error. The fix is conservative — cudaStreamSynchronize per mono stream and cudaDeviceSynchronize at phase boundaries. A more targeted approach using cudaEvent + cudaStreamWaitEvent could preserve more parallelism but requires deeper changes to the Stream/ImageContext ownership model.
Author
|
@aefitorov-nvidia @zwdoescode can you take a look if this is the correct fix for the DGX spark (blackwell)? I tested it on dgx spark it seems works |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fix CUDA error 700 (illegal memory access) on Blackwell GPUs (sm_121) in multi-camera visual odometry. The crash is deterministic at ~200 frames with 6-camera (3 stereo pair) configurations.
Root Cause
MonoSOFGPU::track()builds image pyramids and gradient pyramids on per-camera CUDA streams. These pyramids are later read by stereo pair tracking (LaunchTrackingPrimaryToSecondary) on different per-pair streams, without explicit cross-stream synchronization.On pre-Blackwell GPUs, the implicit memory ordering happened to work. On Blackwell (sm_121), the stricter memory model requires explicit synchronization for cross-stream memory visibility.
Fix
sof_mono_gpu.cpp: AddcudaStreamSynchronizeafter pyramid + gradient build to ensure GPU memory is visible to other streamssof_multicamera_base.cpp: AddcudaDeviceSynchronizebarriers before mono finish and stereo launch phasesTesting
Tested on NVIDIA GB10 (aarch64, CUDA 13, sm_121) with a 6-camera rig (3 stereo pairs), 8075 frames:
cudaDeviceSynchronizebefore stereo launch onlycudaDeviceSynchronizebefore mono finishcudaStreamSynchronizeafter mono pyramid buildCUDA_LAUNCH_BLOCKING=1(reference)compute-sanitizer(reference)Notes
This fix is conservative —
cudaStreamSynchronizeper mono stream andcudaDeviceSynchronizeat phase boundaries. A more targeted approach usingcudaEvent+cudaStreamWaitEventcould preserve more parallelism but requires deeper changes to the Stream/ImageContext ownership model.