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

ncnn::destroy_gpu_instance() causes Segmentation fault on Jetson Nano #978

Closed
iwatake2222 opened this issue May 5, 2019 · 5 comments
Closed

Comments

@iwatake2222
Copy link

iwatake2222 commented May 5, 2019

I built ncnn library with Vulkan support for Jetson Nano and created a simple project to test it.
Inference worked. (The result was a little different from CPU, but still correct and working)

However, when I call ncnn::destroy_gpu_instance() at the end of code, Segmentation fault (core dumped) occurs.
Does anyone have the same problem or is it only me?

When I set net.use_vulkan_compute = 0 , error doesn't happen. So, I think it definitely caused by GPU.

This is my code: https://github.com/take-iwiw/NcnnMultiPlatformProject/blob/master/MyNcnnProject/TestVulkan.cpp

The following might be another topic, but might be related.
To create ncnn library, I basically followed the instruction described here https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-nvidia-jetson
When I built ncnn, I got Could NOT find Vulkan (missing: Vulkan_LIBRARY Vulkan_INCLUDE_DIR) error. Also, I got link error (e.g. pipeline.cpp:(.text+0xf28): undefined reference to vkCreatePipelineLayout' ).
So, as an ugry workaround, I modified CMakeLists.txt like the following. (/mnt/usbm/Vulkanloader_demos_1.1.10 is the directory I extracted Vulkan_loader_demos_1.1.100.tar.gz. )

if(NCNN_VULKAN)
#    find_package(Vulkan REQUIRED)
#    include_directories(${Vulkan_INCLUDE_DIR})
    include_directories("/mnt/usbm/Vulkanloader_demos_1.1.100/include")
    link_libraries(/usr/lib/aarch64-linux-gnu/libvulkan.so)
endif()

I don't think this is the reason of the problem, though.
If anyone know smarter way to build ncnn librarh for Jetson Nano, please tell me.
I think Vulkan is pre-installed with JetPack, but for some reasons, find_package(Vulkan REQUIRED) doesn't work...

Thank you

@iwatake2222
Copy link
Author

I just add the environment info:

  • Jetson Nano (jetson-nano-sd-r32.1-2019-03-18)
    • Copied Vulkan_loader_demos_1.1.100.tar.gz
  • ncnn version: d46c598

@nihui
Copy link
Member

nihui commented May 6, 2019

ncnn::destroy_gpu_instance();

the global instance cleanup should be called after all the other instance destructions

you have to create an inner scope for the Net instance, so that the Net instance destructor is called before ncnn::destroy_gpu_instance();

ncnn::create_gpu_instance();

{
    // do your inference here
}

ncnn::destroy_gpu_instance();

@iwatake2222
Copy link
Author

@nihui
Thank you for the quick response.
I fixed my code and the error has gone.

Again, thank you for creating the great library!!

@nihui
Copy link
Member

nihui commented Dec 19, 2023

#5234

@nihui
Copy link
Member

nihui commented Dec 20, 2023

ded0b78

@nihui nihui reopened this Dec 20, 2023
@nihui nihui closed this as completed Dec 20, 2023
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

No branches or pull requests

2 participants