cudaMalloc reserves memory on the GPU, much like malloc reserves memory on the CPU. It takes the address of a pointer and the requested size, writes the device address through that pointer, and returns an error code. The call blocks until allocation finishes. Reserved memory is uninitialized; allocating it does not copy host data to the GPU. section 2.15
Reserve space for an array
Use cudaMalloc(&d_data, n * sizeof(int)) to reserve GPU memory for n integers. Passing &d_data lets cudaMalloc write the device address into d_data; assigning a return value to d_data would be incorrect. Allocation can fail if device memory runs out. section 2.15
Figure 2.7 Step 1 — Allocate: reserving space on the GPU. cudaMalloc carves out a block of device memory the same size as the host array, but doesn't copy anything yet. The GPU slots contain uninitialized data (the ? marks) until the copy step. Each region is labeled with the pointer that refers to it: h_data for the host array and d_data for the device array, a reminder that they point into two separate memories.

Shows host and device arrays in separate memories, and GPU slots still uninitialized after allocation. section 2.15
