# Error from cudaMemset()

**URL:** <https://forums.developer.nvidia.com/t/error-from-cudamemset/216943>\
**Category:** CUDA Programming and Performance\
**Created:** [June 8, 2022, 12:53pm UTC](https://forums.developer.nvidia.com/t/error-from-cudamemset/216943 "2022-06-08T12:53:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alphikuuuu](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@alphikuuuu](https://forums.developer.nvidia.com/u/alphikuuuu)\
**Post date:** [June 8, 2022, 12:53pm UTC](https://forums.developer.nvidia.com/t/error-from-cudamemset/216943/1 "2022-06-08T12:53:43Z")

</div>

graphics card rtx 3060 ti cuda 11.6. i get cudaErrorIllegalAddress error when i change batch from 1 to 50

```auto
typedef bool boxStatus_t;
boxStatus_t * boxStatus{nullptr};
 
// part of initialization
statusCode
PostprocessingCudaYolo::init(uint8_t batch)
{
    try
    {
    int rs = 0;
 
    rs = cudaMalloc((void **) &(this->boxStatus), YOLO_OUT_SIZE * batch);
    if ( rs != cudaSuccess) {
        return INIT_ERROR;
    }
 
 
// part of running pipeline
statusCode
PostprocessingCudaYolo::clearVectors(uint8_t batch)
{
    try
    {
        
        cudaMemset(this->boxStatus, true , YOLO_OUT_SIZE * batch );
        int r = cudaDeviceSynchronize();
        if (r != cudaSuccess) {
            std::cout << "cudaDeviceSynchronize() return " << r << std::endl;
            return CUDA_ERROR;
        }
 
// if batch == 1 OK
// if batch == 50 cudaDeviceSynchronize() return cudaErrorIllegalAddress
// Why??
```

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [June 8, 2022, 1:23pm UTC](https://forums.developer.nvidia.com/t/error-from-cudamemset/216943/2 "2022-06-08T13:23:47Z")

</div>

One of the kernels launched for the processing associated with the batches is running into an execution error. That error shows up asynchronously (later) when you call `cudaDeviceSynchronize()`. Presumably, the kernel does not hit an error in the batch=1 case, and does hit an error in the batch=50 case.

`cudaMemset` can launch kernels to do its work. If the error is coming from `cudaMemset`, then either the pointer passed is invalid, or the size passed is too large for the pointer (allocation) passed.

---

<div class="post-metadata">

**Author:** ![alphikuuuu](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@alphikuuuu](https://forums.developer.nvidia.com/u/alphikuuuu)\
**Post date:** [June 9, 2022, 5:16am UTC](https://forums.developer.nvidia.com/t/error-from-cudamemset/216943/3 "2022-06-09T05:16:28Z")

</div>

The pointer passed is the same as the pointer when the memory was allocated, the size of the memory is equals. I check it.

---

<div class="post-metadata">

**Author:** ![alphikuuuu](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@alphikuuuu](https://forums.developer.nvidia.com/u/alphikuuuu)\
**Post date:** [June 9, 2022, 7:31am UTC](https://forums.developer.nvidia.com/t/error-from-cudamemset/216943/4 "2022-06-09T07:31:12Z")

</div>

problem is [nppiCopy\_32f\_C3P3R() causes undefined behavior](https://forums.developer.nvidia.com/t/nppicopy-32f-c3p3r-causes-undefined-behavior/217040)
