may i malloc mem on device.

im a newer ,and i wanna to know may malloc mem on device ,thanks.and why.

No, you cannot dynamically allocate memory from device code. However, you can preallocate a large chunk of memory and write your own routines that allocate and deallocate from this space.

not using ‘malloc’ as such, use ‘cudaMalloc’, this will allocate memory that exists on the device.


float* device_buffer;


remember, you cannot directly access this memory on the host without copying over it first.