fix: skip cudaHostRegister when DS4_CUDA_COPY_MODEL_CHUNKED is set#320
Open
kyuz0 wants to merge 1 commit into
Open
fix: skip cudaHostRegister when DS4_CUDA_COPY_MODEL_CHUNKED is set#320kyuz0 wants to merge 1 commit into
kyuz0 wants to merge 1 commit into
Conversation
When DS4_CUDA_COPY_MODEL_CHUNKED is set, skip cudaHostRegister. Registering a large memory map prevents posix_madvise(DONTNEED) from freeing pages during the chunked copy, leading to catastrophic system RAM exhaustion on APUs with unified memory.
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.
Fixes a bug where
DS4_CUDA_COPY_MODEL_CHUNKEDwould still cause host RAM exhaustion during model load on APUs.Context:
Previously, even when
DS4_CUDA_COPY_MODEL_CHUNKED=1was set,ds4_gpu_set_model_mapwould still unconditionally callcudaHostRegisteron the entire memory-mapped model.cudaHostRegisterpage-locks the memory, meaning the chunked copy's subsequentposix_madvise(DONTNEED)calls failed to release the RAM.On AMD APUs like Ryzen AI Max "Strix Halo" (unified memory), this resulted in 80GB+ of system RAM being pinned, completely defeating the purpose of the chunked copy and causing an immediate OOM.
This patch simply exits
ds4_gpu_set_model_mapearly if chunking is enabled, allowing the chunked copy loop to correctly page-in and discard system RAM as intended.