Problems on memory allocation
Hi all,

currently I faced some problems when I try to run my cuda code. I have on program which needs to compute an array of 96*96*96, but sometimes the result will diverge.

However, when I find out my result is diverging, if I run another simple program with a array of 8112*8112 and then back to execute the former code, the result won't diverge.

It just like every time when I need to run my code, I need to use another code to free memory space on my device, otherwise I cannot get my result correct.

I have no idea why this problem will happen, since I just use cudaMalloc() and cudaFree() for my memory allocation and release, please help me on this, thanks a lot.
Hi all,



currently I faced some problems when I try to run my cuda code. I have on program which needs to compute an array of 96*96*96, but sometimes the result will diverge.



However, when I find out my result is diverging, if I run another simple program with a array of 8112*8112 and then back to execute the former code, the result won't diverge.



It just like every time when I need to run my code, I need to use another code to free memory space on my device, otherwise I cannot get my result correct.



I have no idea why this problem will happen, since I just use cudaMalloc() and cudaFree() for my memory allocation and release, please help me on this, thanks a lot.

#1
Posted 04/23/2012 03:45 AM   
There is a problem in the code. Memory access is out of bonds. add the flags -g -G to the compiling line and then run the program with cuda memcheck.
There is a problem in the code. Memory access is out of bonds. add the flags -g -G to the compiling line and then run the program with cuda memcheck.

#2
Posted 04/23/2012 05:21 AM   
hi, pasoleatis

thanks for your reply, I tried it today with compiling my code first with

nvcc -arch=sm_21 -O3 -g -G -o executefile mycode.cu

and then used cuda-memcheck to check like

cuda-memcheck -c ./executefile

However, the report is

=== ERROR SUMMARY: 0 errors

I think it means there is no error in my source code, did I miss something to do or there is really no mistake in my code?
hi, pasoleatis



thanks for your reply, I tried it today with compiling my code first with



nvcc -arch=sm_21 -O3 -g -G -o executefile mycode.cu



and then used cuda-memcheck to check like



cuda-memcheck -c ./executefile



However, the report is



=== ERROR SUMMARY: 0 errors



I think it means there is no error in my source code, did I miss something to do or there is really no mistake in my code?

#3
Posted 04/24/2012 02:41 AM   
Yes. It appears there are no memory problem (outbonds). Did you run the program with 96*96*96? You mentioned the problem does not appear always, so you should run your program until you get a divergence. Post also the output when you get a divergence. Usually when an address is not initialise I get a very large number, negative most of the time.
Yes. It appears there are no memory problem (outbonds). Did you run the program with 96*96*96? You mentioned the problem does not appear always, so you should run your program until you get a divergence. Post also the output when you get a divergence. Usually when an address is not initialise I get a very large number, negative most of the time.

#4
Posted 04/24/2012 10:30 AM   
thank you a lot, pasoleatis, I think the reason causing my problem is just about initialization.

currently I can run my code with a 192*192*192 array size, and what I did was to initialize all variables I declared, which I did do previously.

thanks again.
thank you a lot, pasoleatis, I think the reason causing my problem is just about initialization.



currently I can run my code with a 192*192*192 array size, and what I did was to initialize all variables I declared, which I did do previously.



thanks again.

#5
Posted 04/24/2012 10:56 AM   
After you allocate memory on gpu for an array you can set it all to zero with a cudaset function. You should check why does program read an address which was not written first.
After you allocate memory on gpu for an array you can set it all to zero with a cudaset function. You should check why does program read an address which was not written first.

#6
Posted 04/24/2012 11:44 AM   
Scroll To Top