# Change specific values in a CUDA array ?

**URL:** <https://forums.developer.nvidia.com/t/change-specific-values-in-a-cuda-array/9272>\
**Category:** CUDA Programming and Performance\
**Created:** [May 4, 2009, 4:58pm UTC](https://forums.developer.nvidia.com/t/change-specific-values-in-a-cuda-array/9272 "2009-05-04T16:58:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![divide](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@divide](https://forums.developer.nvidia.com/u/divide)\
**Post date:** [May 4, 2009, 4:58pm UTC](https://forums.developer.nvidia.com/t/change-specific-values-in-a-cuda-array/9272/1 "2009-05-04T16:58:30Z")

</div>

Hello,

Is it possible to change only a few values at different locations in a CUDA array (in GPU memory) without running a kernel through the whole array ?  
If yes, how ?

Thanks

---

<div class="post-metadata">

**Author:** ![divide](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@divide](https://forums.developer.nvidia.com/u/divide)\
**Post date:** [June 19, 2009, 7:57am UTC](https://forums.developer.nvidia.com/t/change-specific-values-in-a-cuda-array/9272/2 "2009-06-19T07:57:19Z")

</div>

up

---

<div class="post-metadata">

**Author:** ![JaredHoberock](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jaredhoberock/32/166135_2.png) [@JaredHoberock](https://forums.developer.nvidia.com/u/JaredHoberock)\
**Post date:** [June 19, 2009, 11:12pm UTC](https://forums.developer.nvidia.com/t/change-specific-values-in-a-cuda-array/9272/3 "2009-06-19T23:12:39Z")

</div>

> [@](#):
>
> up

Sure, you can address specific elements of your array with cudaMemcpy. Or you could just use thrust::device\_vector for memory management:

```auto
#include <thrust/device_vector.h>

int main(void)

{

  thrust::device_vector<int> v(100);

v[50] = 13;

std::cout << "element 50 is: " << v[50] << std::endl;

}

```
