0

I am using C++, GTX1070

I am allocating a cuda array as described:

//variables: Vdepth = 200, Vheight = 100, Vwidth = 100, device = 0 VolumeId = 0
cudaExtent volumeSize = make_cudaExtent(Vdepth, Vheight, Vwidth);
cudaArray *d_volumeArray = NULL;
cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<texture_type>();
VERIFY_CALL( cudaMalloc3DArray(&d_volumeArray, &channelDesc, volumeSize) );
cu_VolArray[device][VolumeId] = d_volumeArray;

Then I try to free it like this:

    VERIFY_CALL(cudaFreeArray(cu_VolArray[device][VolumeId]));
    cu_VolArray[device][VolumeId] = NULL;

using GPUz, allocating will increase GPU memory by 100MB and free will decrease by 10MB - how to clear the extened memory?

this whole code is run through mex in MATLAB (2012a). these "stuck" memory blocks are causing my MATLAB to get stuck (stuck at 'busy') when trying to clear mex_name

talonmies
  • 70,661
  • 34
  • 192
  • 269
  • 1
    CUDA has a number of other memory requirements which accounts for the additional memory consumption you observation. Read more at the marked duplicate – talonmies Mar 31 '19 at 06:44
  • That additional memory is only freed when the CUDA context is destroyed. While ever there is an active context, the fixed memory consumption remains allocated on the GPU – talonmies Apr 01 '19 at 17:31
  • Hi, again - I understand that. My question is why 'clear mex' doesnt free it and how it can be freed, that is why I think you're mistaken as marking this as duplicate. – Daniel Roth Apr 03 '19 at 04:19
  • That is not really the question you initially asked – talonmies Apr 03 '19 at 05:19
  • I've edited your question into what you say are really trying to ask and edited the tags as well. Feel free to edited it further if I have misunderstood anything – talonmies Apr 03 '19 at 05:26
  • When I use MATLAB (tested 2014-2018, most versions) if the mex file returns, it clears and releases almost all the GPU. I tested this by allocating huge arrays on the GPU and not freeing them. The mex file will release them, as far as I can see. That said, once MATLAB has used the GPU, it allocates around 10 MB in each GPU (I can see it in nvidia-smi). This allows faster repeated launches, but does not stack. – Ander Biguri Apr 03 '19 at 09:57
  • `mex clear` would try to compile a MEX-file from a source file `clear`. This will likely lead to an error. Please [edit] your question to clearly state what it is that you do. Maybe you mean `clear mex`? Maybe something else??? – Cris Luengo Apr 03 '19 at 14:03
  • @CrisLuengo: That is probably my fault.. The original question something like "why does CUDA malloc allocate more memory that I ask for and stop a mex from clearing", which is nonsense from a CUDA perspective. My edit is probably nonsense from a Matlab perspective , I admit to knowing nothing about it. Please edit it to make for sense if it bothers you – talonmies Apr 03 '19 at 15:00
  • @talonmies: I’m not going to edit the question because I have no idea what OP did. I’m voting to close as unclear until the Q gets edited to be correct and complete. – Cris Luengo Apr 03 '19 at 15:42
  • now edited as requested – Daniel Roth May 13 '19 at 11:19

0 Answers0