Skip to content

[CUDA] illegal memory write on PopulationCount #104077

Closed

Description

@kokol16

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

No

Source

source

TensorFlow version

tf 2.20

Custom code

Yes

OS platform and distribution

Ubuntu 22.04

Mobile device

No response

Python version

3.10

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

CUDA 12.5.1, cuDNN 9.2.1

GPU model and memory

No response

Current behavior?

Compute-Sanitizer reports an out of bounds Write on PopulationCountKernel

Standalone code to reproduce the issue

# PopulationCountOp

import tensorflow as tf

x = tf.constant(1, shape=[2147483647], dtype=tf.int8)
tf.raw_ops.PopulationCount(x=x)

Relevant log output

========= Invalid __global__ write of size 1 bytes
=========     at void tensorflow::functor::PopulationCountKernel<signed char>(int, const T1 *, unsigned char *)+0x140
=========     by thread (416,0,0) in block (31,0,0)
=========     Address 0x7ef7470403a0 is out of bounds
=========     and is 929 bytes after the nearest allocation at 0x7ef1d4000000 of size 23404478464 bytes

Activity

  1. added
    comp:ops
    on Nov 10, 2025
  2. Venkat6871 commented on Nov 24, 2025

    @Venkat6871
    Contributor

    Hi @kokol16 ,
    Apologies for the delay, I tried reproducing your code with TensorFlow 2.20.0 on GPU, and I am also seeing a failure when using the very large shape value 2147483647. On my setup, it results in a CUDA illegal memory access error:

    InternalError: CUDA error: Could not synchronize CUDA stream: CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered
    

    When I reduce the shape to a smaller value, the PopulationCount op works normally. So the behavior matches what you observed the extremely large tensor size is causing the kernel to access memory out of bounds.

    I am attaching a Colab gist for reference.
    Hope this helps, and thank you again for reporting this.

  3. added
    stat:awaiting response
    on Nov 24, 2025
  4. github-actions commented on Dec 2, 2025

    @github-actions

    This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you.

  5. added
    stale
    on Dec 2, 2025
  6. github-actions commented on Dec 9, 2025

    @github-actions

    This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further.

  7. google-ml-butler commented on Dec 9, 2025

    @google-ml-butler

    Are you satisfied with the resolution of your issue?
    Yes
    No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

TF 2.19comp:opsstalestat:awaiting responsetype:bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions