0

I am using thrust with cuda 5.5 to make integer vector sort. Sorting 100*1024*1024 int's should allocate 400MB memory,but nvidia-smi shows always "Memory-Usage 105MB / 1023MB".(my test GPU is GTX260M)

sorting 150*1024*1024 gives allocation error:

terminate called after throwing an instance of 'thrust::system::detail::bad_alloc'
  what():  std::bad_alloc: out of memory
Aborted (core dumped)

before array allocation I am checking memory using cudaMemGetInfo it returns:

GPU memory usage: used = 105.273682, free = 918.038818 MB, total = 1023.312500 MB

Can I check maximum memory available for my integer array before starting gpu analysis?

EDIT:

Ok, before sort my memory usage is about this. GPU memory usage: used = 545.273682, free = 478.038818 MB, total = 1023.312500 MB

seems to me sort algorithm needs some additional memory.

Arman
  • 4,566
  • 10
  • 45
  • 66
  • I guess there's something wrong with your GetInfo. As said you're allocating 400MB first and then try to allocate another 600MB, which is to much for your slightly-less-than-1000MB device. – Jonas Bötel Jan 28 '14 at 20:19
  • Ok I checked nvidia-smi doesnot show correct usage. – Arman Jan 28 '14 at 20:43

1 Answers1

1

Thrust sorting operations require significant extra temporary storage.

nvidia-smi is effectively sampling memory usage at various times, and the amount of memory in use at the sampling point may not be reflective of the max memory used (or required) by your application. As you've discovered cudaMemGetInfo may be more useful.

I've generally found thrust to be able to sort arrays up to about 40% of the memory on your GPU. However there is no specified number and you may need to determine it by trial and error.

Don't forget that CUDA uses some overhead memory, and if your GPU is hosting a display, that will consume additional memory as well.

Community
  • 1
  • 1
Robert Crovella
  • 143,785
  • 11
  • 213
  • 257
  • Yes that was a trouble. I checked on Tesla w/o display, I got 2.8GB out of 3GB. On laptop my 150Mb is always used, but somehow. On Tesla nvidia-smi shows correct memory usage but not on laptop;(. – Arman Jan 31 '14 at 15:36