Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid double frees in sample code #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

ahnolds
Copy link

@ahnolds ahnolds commented Nov 1, 2020

There are incorrect and unnecessary calls to nppiFree in two of the sample NPP applications (box filter and canny edge detector).

The device memory for the image will be automatically freed when the image destructor is called (i.e. when it goes out of scope at the end of the program). Explicitly freeing it separately causes an error on the call to nppiFree the same memory in the destructor for the image, as evidenced by running cuda-memcheck:

========= CUDA-MEMCHECK                                                                                                                                                                                                    
========= Program hit cudaErrorInvalidDevicePointer (error 17) due to "invalid device pointer" on CUDA API call to cudaFree.                                                                                               
=========     Saved host backtrace up to driver entry point at error                                                                                                                                                       
=========     Host Frame:/usr/lib/x86_64-linux-gnu/libcuda.so.1 [0x3451c3]                                                                                                                                                 
=========     Host Frame:/usr/local/cuda-8.0/targets/x86_64-linux/lib/libnppisu.so.8.0 [0x45616]                                                                                                                           
=========     Host Frame:./assignment_npp.exe [0x9835]                                                                                                                                                                     
=========     Host Frame:./assignment_npp.exe [0xa71b]                                                                                                                                                                     
=========     Host Frame:./assignment_npp.exe [0xa0ee]                                                                                                                                                                     
=========     Host Frame:./assignment_npp.exe [0x8d60]                                                                                                                                                                     
=========     Host Frame:/lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main + 0xf0) [0x20840]                                                                                                                              
=========     Host Frame:./assignment_npp.exe [0x6bd9]                                                                                                                                                                     
=========                                                                                                                                                                                                                  
========= Program hit cudaErrorInvalidDevicePointer (error 17) due to "invalid device pointer" on CUDA API call to cudaFree.                                                                                               
=========     Saved host backtrace up to driver entry point at error                                                                                                                                                       
=========     Host Frame:/usr/lib/x86_64-linux-gnu/libcuda.so.1 [0x3451c3]                                                                                                                                                 
=========     Host Frame:/usr/local/cuda-8.0/targets/x86_64-linux/lib/libnppisu.so.8.0 [0x45616]                                                                                                                           
=========     Host Frame:./assignment_npp.exe [0x9835]                                                                                                                                                                     
=========     Host Frame:./assignment_npp.exe [0xa71b]                                                                                                                                                                     
=========     Host Frame:./assignment_npp.exe [0xa0ee]                                                                                                                                                                     
=========     Host Frame:./assignment_npp.exe [0x8d6c]                                                                                                                                                                     
=========     Host Frame:/lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main + 0xf0) [0x20840]                                                                                                                              
=========     Host Frame:./assignment_npp.exe [0x6bd9]                                                                                                                                                                     
=========                                                                                                                                                                                                                  
========= ERROR SUMMARY: 2 errors                                                                                                                                                                                          

The device memory for the image will be automatically freed when the image object itself is destroyed.
The device memory for the image will be automatically freed when the image object itself is destroyed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant