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

What if the gpu doesn't support support_int8_storage? #38

Open
tumuyan opened this issue Feb 15, 2022 · 3 comments
Open

What if the gpu doesn't support support_int8_storage? #38

tumuyan opened this issue Feb 15, 2022 · 3 comments

Comments

@tumuyan
Copy link

tumuyan commented Feb 15, 2022

Some derive doesn't support support_int8_storage, just print “fp16p/s/a=1/1/1 int8-p/s/a=1/0/1” and "vkQueueSubmit failed -4"

I find this

net.opt.use_int8_storage = true;

and this

if (net.opt.use_fp16_storage && net.opt.use_int8_storage)


          if (net.opt.use_fp16_storage && net.opt.use_int8_storage)
                realsr_preproc->create(realsr_preproc_int8s_spv_data, sizeof(realsr_preproc_int8s_spv_data), specializations);
            else if (net.opt.use_fp16_storage)
                realsr_preproc->create(realsr_preproc_fp16s_spv_data, sizeof(realsr_preproc_fp16s_spv_data), specializations);
            else
                realsr_preproc->create(realsr_preproc_spv_data, sizeof(realsr_preproc_spv_data), specializations);

            if (net.opt.use_fp16_storage && net.opt.use_int8_storage)
                realsr_postproc->create(realsr_postproc_int8s_spv_data, sizeof(realsr_postproc_int8s_spv_data), specializations);
            else if (net.opt.use_fp16_storage)
                realsr_postproc->create(realsr_postproc_fp16s_spv_data, sizeof(realsr_postproc_fp16s_spv_data), specializations);
            else
                realsr_postproc->create(realsr_postproc_spv_data, sizeof(realsr_postproc_spv_data), specializations);

(net.opt.use_fp16_storage && net.opt.use_int8_storage) always be true.

So I fixed the code as:


RealSR::RealSR(int gpuid, bool _tta_mode)
{
    const ncnn::GpuInfo& gpuInfo =  ncnn::get_gpu_info(gpuid);

    net.opt.use_vulkan_compute = true;
    net.opt.use_fp16_packed = gpuInfo.support_int8_packed();
    net.opt.use_fp16_storage = gpuInfo.support_fp16_storage();
    net.opt.use_fp16_arithmetic = false;
    net.opt.use_int8_storage = gpuInfo.support_int8_storage();
    net.opt.use_int8_arithmetic = false;

    net.set_vulkan_device(gpuid);

    realsr_preproc = 0;
    realsr_postproc = 0;
    bicubic_4x = 0;
    tta_mode = _tta_mode;
}


Does the modify is unnecessary?

@ArchieMeng
Copy link
Contributor

ArchieMeng commented Feb 16, 2022

It's a known issue.
I run realsr on snapdragon 865 with -t 64 option, and it works well. The default tilesize doesn't work for smartphones.
Tencent/ncnn#2636
#20

Update:

I used waifu2x_srmd_termux to run realsr on Android devices. If I didn't make it wrong, I guess you were using your RealSR NCNN Android to run it.
I have read a part of the source code in the RealSR NCNN CLI, I guess the reason may be that it used an incorrect CMakeList.txt configuration to build it.

@tumuyan
Copy link
Author

tumuyan commented Feb 16, 2022

It's a known issue.
I run realsr on snapdragon 865 with -t 64 option, and it works well. The default tilesize doesn't work for smartphones.

Thank for your reply. Same result but may have different reason.

In Tencent/ncnn#2636 , the patch is turn off both net.opt.use_fp16_storage and net.opt.use_int8_storage ;
If it works well, define net.opt.use_fp16_storage and net.opt.use_int8_storage by GPUinfo is a fine solution.

In #20 , the print info is fp16p/s/a=1/1/0 int8-p/s/a=1/1/1
but net.opt.use_fp16_arithmetic and net.opt.use_int8_arithmetic are defined to false, so it may cause of VRAM/RAM not enough. But how many VRAM/RAM does it used when the error happened? We don't know. In fact, when I ran it on my PC, I didn't see a very high usage. I guess there is another bug

if the root reason is tilesize, the default value should be fixed.

if (heap_budget > 1900)

I used waifu2x_srmd_termux to run realsr on Android devices. If I didn't make it wrong, I guess you were using your RealSR NCNN Android to run it.

The error occurred on someone else's device, everything fine my device.

@ArchieMeng
Copy link
Contributor

ArchieMeng commented Feb 16, 2022

I guess these options are just "prefer" options rather than "force" options. I read the document, and it seems like (when they are set as true) they are enabled only if the end device is capable of it. I am not sure, please ask @nihui .

My evidence is that, my waifu2x ncnn android didn't change the waifu2x.cpp source code and leave net.opt.use_int8_storage as true. None of my smartphones support int8_storage function, but they run the app without any problems. I think this explains a lot.

Additionally, I suggest you to modified the CMakeList.txt according to the existing ncnn android demos. Such as https://github.com/nihui/ncnn-android-nanodet and https://github.com/nihui/ncnn-android-scrfd. And rebuild the app to see if the problem is solved.

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