nihui / waifu2x-ncnn-vulkan

waifu2x converter ncnn version, runs fast on intel / amd / nvidia / apple-silicon GPU with vulkan
MIT License
3.01k stars 210 forks source link

Failed to run by CPU on CentOS7 #186

Open nuzou1 opened 2 years ago

nuzou1 commented 2 years ago

vkCreateInstance failed -9 vkCreateInstance failed -9 Error in `./waifu2x-ncnn-vulkan': double free or corruption (out): 0x00007f80fd4b9040 ======= Backtrace: ========= /lib64/libc.so.6(+0x81329)[0x7f81a5433329] ./waifu2x-ncnn-vulkan[0x8e6238] ./waifu2x-ncnn-vulkan[0x8e6ae5] /lib64/libpthread.so.0(+0x7ea5)[0x7f81a60a5ea5] /lib64/libc.so.6(clone+0x6d)[0x7f81a54b0b0d] ======= Memory map: ======== 00400000-00a84000 r-xp 00000000 fd:01 1442241 /data/project/waifu2x-ncnn-vulkan/models/waifu2x-ncnn-vulkan 00c83000-00c9a000 r--p 00683000 fd:01 1442241 /data/project/waifu2x-ncnn-vulkan/models/waifu2x-ncnn-vulkan 00c9a000-00c9c000 rw-p 0069a000 fd:01 1442241 /data/project/waifu2x-ncnn-vulkan/models/waifu2x-ncnn-vulkan 00c9c000-00caf000 rw-p 00000000 00:00 0 017b5000-03087000 rw-p 00000000 00:00 0 [heap] 7f80fcaf4000-7f819c000000 rw-p 00000000 00:00 0 7f819c000000-7f819cfd1000 rw-p 00000000 00:00 0 7f819cfd1000-7f81a0000000 ---p 00000000 00:00 0 7f81a0485000-7f81a1b84000 rw-p 00000000 00:00 0 7f81a1b84000-7f81a1b85000 ---p 00000000 00:00 0 7f81a1b85000-7f81a2385000 rw-p 00000000 00:00 0 7f81a2385000-7f81a2386000 ---p 00000000 00:00 0 7f81a2386000-7f81a2b86000 rw-p 00000000 00:00 0 7f81a2b86000-7f81a2b87000 ---p 00000000 00:00 0 7f81a2b87000-7f81a3387000 rw-p 00000000 00:00 0 7f81a3387000-7f81a3388000 ---p 00000000 00:00 0 7f81a3388000-7f81a4009000 rw-p 00000000 00:00 0 7f81a448a000-7f81a468b000 rw-p 00000000 00:00 0 7f81a488c000-7f81a488d000 ---p 00000000 00:00 0 7f81a488d000-7f81a508d000 rw-p 00000000 00:00 0 7f81a51ae000-7f81a51b0000 r-xp 00000000 fd:01 787837 /usr/lib64/libdl-2.17.so

nuzou1 commented 2 years ago

after run yum install mesa-vulkan-drivers

vkEnumeratePhysicalDevices failed -3 Error in `./waifu2x-ncnn-vulkan': double free or corruption (out): 0x00007f295b3bb040 ======= Backtrace: ========= /lib64/libc.so.6(+0x81329)[0x7f2a08dea329] ./waifu2x-ncnn-vulkan[0x8e6238] ./waifu2x-ncnn-vulkan[0x8e6ae5] /lib64/libpthread.so.0(+0x7ea5)[0x7f2a09a5cea5] /lib64/libc.so.6(clone+0x6d)[0x7f2a08e67b0d] ======= Memory map: ======== 00400000-00a84000 r-xp 00000000 fd:01 1442241 /data/project/waifu2x-ncnn-vulkan/models/waifu2x-ncnn-vulkan 00c83000-00c9a000 r--p 00683000 fd:01 1442241 /data/project/waifu2x-ncnn-vulkan/models/waifu2x-ncnn-vulkan 00c9a000-00c9c000 rw-p 0069a000 fd:01 1442241 /data/project/waifu2x-ncnn-vulkan/models/waifu2x-ncnn-vulkan 00c9c000-00caf000 rw-p 00000000 00:00 0 01f4c000-03935000 rw-p 00000000 00:00 0 [heap]

nuzou1 commented 2 years ago

vulkaninfo

========== VULKANINFO

Vulkan Instance Version: 1.1.97

/builddir/build/BUILD/Vulkan-Tools-sdk-1.1.97.0/vulkaninfo/vulkaninfo.c:3847: failed with VK_ERROR_INITIALIZATION_FAILED

ArchieMeng commented 2 years ago

Same here. My mobile app is also affected. And it is confirmed on my PC.

According to the debugging result on Waifu2x ncnn, this is caused by the following lines of code in process_cpu():

if (channels == 4)
{
    memcpy(out.channel_range(3, 1), out_alpha_tile, out_alpha_tile.total() * sizeof(float));
}

And it only crashes on large RGBA images. (no crash confirmed on images probably smaller than 860x640)

The ncnn lib known to cause these crashes is 20220729. when compiled with version 20220721, it won't crash.

Backtrace log on PC:

(gdb) bt
#0  0x00007ffff79b949c in ?? () from /usr/lib/libc.so.6
#1  0x00007ffff7969958 in raise () from /usr/lib/libc.so.6
#2  0x00007ffff795353d in abort () from /usr/lib/libc.so.6
#3  0x00007ffff79ad63e in ?? () from /usr/lib/libc.so.6
#4  0x00007ffff79c322c in ?? () from /usr/lib/libc.so.6
#5  0x00007ffff79c5360 in ?? () from /usr/lib/libc.so.6
#6  0x00007ffff79c79f3 in free () from /usr/lib/libc.so.6
#7  0x000055555597e974 in ncnn::fastFree (ptr=<optimized out>) at /home/archiemeng/OpenSourceProjects/waifu2x-ncnn-vulkan/src/ncnn/src/allocator.h:99
#8  ncnn::Mat::release (this=<optimized out>, this=<optimized out>) at /home/archiemeng/OpenSourceProjects/waifu2x-ncnn-vulkan/src/ncnn/src/mat.h:1180
#9  ncnn::Mat::~Mat (this=<optimized out>, this=<optimized out>) at /home/archiemeng/OpenSourceProjects/waifu2x-ncnn-vulkan/src/ncnn/src/mat.h:894
#10 Waifu2x::process_cpu (this=this@entry=0x555555cc8ed0, inimage=..., outimage=...) at /home/archiemeng/OpenSourceProjects/waifu2x-ncnn-vulkan/src/waifu2x.cpp:855
#11 0x0000555555982400 in Waifu2x::process(ncnn::Mat const&, ncnn::Mat&) const [clone .isra.0] (this=this@entry=0x555555cc8ed0, inimage=..., outimage=...)
    at /home/archiemeng/OpenSourceProjects/waifu2x-ncnn-vulkan/src/waifu2x.cpp:150
#12 0x00005555555902c7 in proc (args=<optimized out>) at /home/archiemeng/OpenSourceProjects/waifu2x-ncnn-vulkan/src/main.cpp:361
#13 0x00007ffff79b774d in ?? () from /usr/lib/libc.so.6
#14 0x00007ffff7a39700 in ?? () from /usr/lib/libc.so.6