-
Notifications
You must be signed in to change notification settings - Fork 208
fix: prevent cross-process GPU memory overcommit on concurrent cuMemAlloc. #273
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
Liauuu
wants to merge
8
commits into
Project-HAMi:main
Choose a base branch
from
Liauuu:race-fix
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
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7acc53c
test: add cross-process oom_check TOCTOU reproducer
Liauuu 31817c2
fix: reserve shared GPU memory before CUDA alloc
Liauuu aebc88b
refactor: address CodeRabbit review feedback on race fix and test har…
Liauuu e8a1fd2
fix: handle add_chunk_only failures and skip GPU-less CTest
Liauuu bc1d442
style: use uint64_t instead of long in alloc race window
Liauuu 0cad214
style: reject negative HAMI_ALLOC_RACE_WINDOW_US
Liauuu 1958fc1
fix: avoid nested lock_shrreg in oom_check during reserve
Liauuu d4dfbd0
refactor: remove test-only alloc race window from allocator.
Liauuu 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/usr/bin/env bash | ||
| # Run the cross-process oom_check race test against libvgpu.so. | ||
| # Default: --expect-fixed (limit must hold under concurrent alloc). | ||
| # Exit 77 = no GPU (CTest SKIP_RETURN_CODE). | ||
| set -euo pipefail | ||
|
|
||
| ROOT="$(cd "$(dirname "$0")/.." && pwd)" | ||
| LIB="${LIBVGPU:-$ROOT/build/libvgpu.so}" | ||
| BIN="${TEST_BIN:-$ROOT/build/test/test_concurrent_oom_race}" | ||
| CACHE="${CUDA_DEVICE_MEMORY_SHARED_CACHE:-/tmp/hami_oom_race.cache}" | ||
| LIMIT="${CUDA_DEVICE_MEMORY_LIMIT:-1024m}" | ||
| ALLOC="${HAMI_RACE_ALLOC:-600m}" | ||
| ROUNDS="${HAMI_RACE_ROUNDS:-30}" | ||
|
|
||
| # Detect a usable NVIDIA GPU before LD_PRELOAD so CPU-only hosts skip cleanly. | ||
| if ! command -v nvidia-smi >/dev/null 2>&1 || ! nvidia-smi -L >/dev/null 2>&1; then | ||
| echo "SKIP: no NVIDIA GPU available (nvidia-smi)" >&2 | ||
| exit 77 | ||
| fi | ||
|
|
||
| if [[ ! -f "$LIB" ]]; then | ||
| echo "missing $LIB — build first: (cd \"$ROOT\" && ./build.sh)" >&2 | ||
| exit 1 | ||
| fi | ||
| if [[ ! -x "$BIN" ]]; then | ||
| echo "missing $BIN — rebuild so test/CMakeLists.txt picks up the new test" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| mkdir -p /tmp/vgpulock | ||
| rm -f "$CACHE" | ||
|
|
||
| export LD_PRELOAD="$LIB" | ||
| export CUDA_DEVICE_MEMORY_SHARED_CACHE="$CACHE" | ||
| export CUDA_DEVICE_MEMORY_LIMIT="$LIMIT" | ||
| export HAMI_RACE_ALLOC="$ALLOC" | ||
| export HAMI_RACE_ROUNDS="$ROUNDS" | ||
| export LIBCUDA_LOG_LEVEL="${LIBCUDA_LOG_LEVEL:-1}" | ||
|
|
||
| # Default to verifying the fix; omit args only triggers --expect-fixed. | ||
| ARGS=("$@") | ||
| if [[ ${#ARGS[@]} -eq 0 ]]; then | ||
| ARGS=(--expect-fixed) | ||
| fi | ||
|
|
||
| echo "Running: $BIN ${ARGS[*]}" | ||
| echo " LD_PRELOAD=$LD_PRELOAD" | ||
| echo " LIMIT=$LIMIT ALLOC=$ALLOC ROUNDS=$ROUNDS" | ||
| echo " CACHE=$CACHE" | ||
| exec "$BIN" "${ARGS[@]}" |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.