Skip to content

Fix CUDA error 700 (illegal address) in gpu_batch mode#178

Open
caic99 wants to merge 2 commits intodptech-corp:mainfrom
caic99:fix/cudamemset-pointer-bug-115
Open

Fix CUDA error 700 (illegal address) in gpu_batch mode#178
caic99 wants to merge 2 commits intodptech-corp:mainfrom
caic99:fix/cudamemset-pointer-bug-115

Conversation

@caic99
Copy link
Copy Markdown
Member

@caic99 caic99 commented Apr 10, 2026

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 the ig_cuda_gpu pointer, 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

  • Build with CUDA and verify compilation
  • Run gpu_batch with multiple batches → should complete without CUDA error 700

🤖 Generated with Claude Code

…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>
@caic99 caic99 closed this Apr 20, 2026
@caic99 caic99 reopened this Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CUDA Runtime Error when using ad4 maps

1 participant