Fix CUDA error 700 (illegal address) in gpu_batch mode#178
Open
caic99 wants to merge 2 commits intodptech-corp:mainfrom
Open
Fix CUDA error 700 (illegal address) in gpu_batch mode#178caic99 wants to merge 2 commits intodptech-corp:mainfrom
caic99 wants to merge 2 commits intodptech-corp:mainfrom
Conversation
…cudaMemset pointer `cudaMemset(&ig_cuda_gpu, ...)` at monte_carlo.cu:1481 passes the address of the local pointer variable (on CPU stack) instead of the GPU buffer pointer value. This corrupts the `ig_cuda_gpu` pointer itself, causing all subsequent GPU memory accesses to hit illegal addresses (CUDA error 700). The first batch may succeed because the corrupted pointer partially overlaps valid GPU memory, but by the second batch the pointer is garbage. The correct pattern `cudaMemset(ig_cuda_gpu, ...)` (without `&`) is already used at line 687 for the same purpose. Fix: remove the erroneous `&`. Fixes dptech-corp#115, dptech-corp#118, dptech-corp#136 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 10, 2026
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
Root cause:
cudaMemset(&ig_cuda_gpu, 0, ...)at monte_carlo.cu:1481 passes the address of the local pointer variable (on CPU stack) instead of the GPU buffer pointer. This corrupts theig_cuda_gpupointer, causing all subsequent GPU memory accesses to hit illegal addresses.The correct pattern
cudaMemsetAsync(ig_cuda_gpu, 0, ...)is used at line 687 for the same purpose. This is a one-character fix removing the erroneous&.Why it manifests on second+ batches
The first batch may succeed because the corrupted pointer happens to still partially overlap valid GPU memory. By the second batch, the pointer is garbage → illegal address at cudaDeviceSynchronize.
Test plan
🤖 Generated with Claude Code