Skip to content

[vulkan] Failed: Some allocations were not freed before destruction of this memory block #2948

Closed

Description

@denis0x0D

Hello, I'm facing the error "Check failed: m_pMetadata->IsEmpty() && "Some allocations were not freed before destruction of this memory block!" while running simple.mlir on Samsung S9 (QP1A.190711.020.G960FXXSBETH1)

$ build-android/host/bin/iree-translate \
    -iree-mlir-to-vm-bytecode-module \
    -iree-hal-target-backends=vulkan-spirv \
    iree/tools/test/simple.mlir \
    -o /tmp/simple-vulkan.vmfb
starlte:/data/local/tmp $ ./iree-benchmark-module -driver=vulkan -input_file=simple-vulkan.vmfb -entry_function=abs -inputs="i32=2"                                                                       
2020-08-20 00:37:18
Running ./iree-benchmark-module
Run on (8 X 1794 MHz CPU s)
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
I ../iree/tools/vm_util.cc:227] Creating driver and device for 'vulkan'...
I ../iree/hal/vulkan/vulkan_driver.cc:298] Created Vulkan Device: Mali-G72
F ../third_party/vulkan_memory_allocator/src/vk_mem_alloc.h:11175] Check failed: m_pMetadata->IsEmpty() && "Some allocations were not freed before destruction of this memory block!" 
Aborted 

@antiagainst can you please share, have you seen this issue?

Activity

  1. added
    platform/android 🤖
    bug 🐞
    hal/vulkan
    on Aug 20, 2020
  2. antiagainst commented on Aug 24, 2020

    @antiagainst
    Member

    Hi @denis0x0D, thanks for the report! Sorry for the late reply; I'm on leave at the moment.

    I haven't hit such issues thus far and I don't have a S9 with me. But wondering whether one can reproduce it on S10. @hanhanW could you give it a try to see whether this is reproducible?

  3. hanhanW commented on Aug 24, 2020

    @hanhanW
    Contributor

    Oh, sorry I didn't see the issue. Yes, I will take a look if this is reproducible on S10.

  4. hanhanW commented on Aug 24, 2020

    @hanhanW
    Contributor

    Yes, this is reproducible on S10. I also tried, this is reproducible on desktop GPU as well.

    The full log

    I ../iree/tools/vm_util.cc:227] Creating driver and device for 'vulkan'...
    E ../iree/hal/vulkan/debug_reporter.cc:40] libSPIRV-Tools-opt.so: cannot open shared object file: No such file or directory
    E ../iree/hal/vulkan/debug_reporter.cc:40] libSPIRV-Tools-opt.so: cannot open shared object file: No such file or directory
    [vk_mem_alloc.h : 15777] RAW: vmaCreateAllocator
    I ../iree/hal/vulkan/vulkan_driver.cc:298] Created Vulkan Device: Quadro P1000
    [vk_mem_alloc.h : 16824] RAW: vmaCreateBuffer
    [vk_mem_alloc.h : 14433] RAW:   AllocateMemory: MemoryTypeIndex=10, AllocationCount=1, Size=256
    [vk_mem_alloc.h : 11744] RAW:     Created new block Size=8388608
    [vk_mem_alloc.h : 16824] RAW: vmaCreateBuffer
    [vk_mem_alloc.h : 14433] RAW:   AllocateMemory: MemoryTypeIndex=9, AllocationCount=1, Size=256
    [vk_mem_alloc.h : 11744] RAW:     Created new block Size=8388608
    [vk_mem_alloc.h : 16934] RAW: vmaDestroyBuffer
    [vk_mem_alloc.h : 11934] RAW:   Freed from MemoryTypeIndex=9
    [vk_mem_alloc.h : 16824] RAW: vmaCreateBuffer
    [vk_mem_alloc.h : 14433] RAW:   AllocateMemory: MemoryTypeIndex=9, AllocationCount=1, Size=256
    [vk_mem_alloc.h : 11648] RAW:     Returned from existing block #0
    [vk_mem_alloc.h : 16934] RAW: vmaDestroyBuffer
    [vk_mem_alloc.h : 11934] RAW:   Freed from MemoryTypeIndex=9
    [vk_mem_alloc.h : 15787] RAW: vmaDestroyAllocator
    F ../third_party/vulkan_memory_allocator/src/vk_mem_alloc.h:11175] Check failed: m_pMetadata->IsEmpty() && "Some allocations were not freed before destruction of this memory block!"
    
  5. hanhanW commented on Aug 24, 2020

    @hanhanW
    Contributor

    It seems like the same issue #2455 ?

    @benvanik is there any PRs that might cause this issue recently?

    I'll investigate if this can be revealed via ASAN for other backends.

  6. self-assigned this
    on Aug 24, 2020
  7. added
    runtime
    and removed
    platform/android 🤖
    on Aug 24, 2020
  8. hanhanW commented on Aug 24, 2020

    @hanhanW
    Contributor

    Can't reproduce with ASAN in VMLA, seems to be vulkan specific issue.

  9. antiagainst commented on Aug 24, 2020

    @antiagainst
    Member

    Regression just never ends. :( We probably want to put iree-benchmark-module in the tests too by controlling the total run time to get basic check for it.

    iree-run-module is fine; so I'd be curious of the differences between iree-run-module and iree-benchmark-module. Likely because we have an loop in it trying to creating resources multiple times but without proper releasing?

    A few things that helps to debug:

    • uncomment IREE_VERBOSE_REF_PTR
    • set IREE_DISPATCH_LOGGING to 1
    • ...
  10. lioujheyu commented on Aug 24, 2020

    @lioujheyu

    Hello, I want to report the same issue on desktop GPU but with python binding. What I do is basically wrapping the SyetemContext in a loop and this error occurred every time after like 10 iterations. Here is the error message when this occurred.

    I iree/hal/vulkan/vulkan_driver.cc:298] Created Vulkan Device: Tesla P100-PCIE-16GB
    Created IREE driver vulkan: <pyiree.rt.binding.HalDriver object at 0x7fd370087960>
    I iree/hal/vulkan/vulkan_driver.cc:298] Created Vulkan Device: Tesla P100-PCIE-16GB
    SystemContext driver=<pyiree.rt.binding.HalDriver object at 0x7fd370087960>
    F external/vulkan_memory_allocator/src/vk_mem_alloc.h:11175] Check failed: m_pMetadata->IsEmpty() && "Some allocations were not freed before destruction of this memory block!"
    

    Hopefully, this can help with finding the root cause.

  11. denis0x0D commented on Aug 26, 2020

    @denis0x0D
    Author

    @antiagainst @hanhanW thanks for looking on this issue and suggestions!

  12. hanhanW commented on Aug 26, 2020

    @hanhanW
    Contributor

    The benchmarking tool will try to iterate 10, 100, 1000, 10000... times

    https://github.com/google/iree/blob/6bd3b1dc13236566d1f8ee651cd3ab9b03dd8a1d/iree/tools/benchmark_module_main.cc#L137-L149

    It works if you break the loop earlier, like right after the 127 iteration, on vulkan.

    I count on the iterations, it seems that it can only execute 128 times in the loop.

    It looks like it's related to kMaxInFlightFenceCount. If I set it to 64 then it can only iterate 64 times.

    https://github.com/google/iree/blob/6bd3b1dc13236566d1f8ee651cd3ab9b03dd8a1d/iree/hal/vulkan/timepoint_util.h#L123

  13. hanhanW commented on Aug 26, 2020

    @hanhanW
    Contributor

    And 256 times if I set the number to 256.

  14. hanhanW commented on Aug 26, 2020

    @hanhanW
    Contributor

    @ScottTodd could you take a look at this?

  15. ScottTodd commented on Aug 26, 2020

    @ScottTodd
    Member

    Can you try with #2800 ? That would be nice to land, but it's tricky to know for sure if each of the changes in that area are fixing issues without causing more :/

  16. hanhanW commented on Aug 26, 2020

    @hanhanW
    Contributor

    That is working with another change I have. We need to release the input before others. Ie, add inputs.reset(); after the loop. I'll send out the PR for releasing inputs.

  17. hanhanW commented on Aug 26, 2020

    @hanhanW
    Contributor

    hmm, it just works with my patch. I remembered I tried it this afternoon, but it's not working. Anyway, I'll send out the PR to fix this.

  18. antiagainst commented on Aug 27, 2020

    @antiagainst
    Member

    Thanks for looking into it and fixing this, @hanhanW!

  19. lioujheyu commented on Oct 7, 2020

    @lioujheyu

    Hello,

    It seems the same Vulkan memory leak problem is still in the python binding. The simplest way to reproduce the error is to take colab's low level invoke example. Put everything except the import in an infinite loop. Also, change the driver_name to "vulkan" and run it.

    On my machine with Nvidia P100 GPU, the exception: "Check failed: m_pMetadata->IsEmpty() && "Some allocations were not freed before destruction of this memory block!" always pops up in the iteration 83.

  20. hanhanW commented on Oct 7, 2020

    @hanhanW
    Contributor

    Can it be reproduced in tool level on your machine? Ie, compile the simple_mul with iree-translate and run on iree-run-benchmark.

  21. lioujheyu commented on Oct 7, 2020

    @lioujheyu

    No, it cannot be reproduced in iree-translate/iree-benchmark-module. Think the issue is specific to the python binding.

  22. hanhanW commented on Oct 7, 2020

    @hanhanW
    Contributor

    Let's move the discussion to #3381, since it only happens on python binding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐞hal/vulkanruntime

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions