That isn’t right. I’m not saying its the source of your problem (which isn’t evident here; however you haven’t shown any code that actually copies non-zero values to random_array).
You may want to remind yourself of basic CUDA programming concepts by studying a code like vectorAdd.