Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

RuntimeError: Didn't find engine for operation quantized::linear_prepack NoQEngine on running the docker container #5

Closed
rplevka opened this issue Nov 16, 2020 · 3 comments
Projects

Comments

@rplevka
Copy link

rplevka commented Nov 16, 2020

Hello, I tried the Quickstart steps and I can't get through this error. Did I miss something?
Thanks!

# docker run -it -p 8080:8080 iceychris/libreasr:latest
make sde &
make sen &
make b
make[1]: Entering directory '/workspace'
python3 -u api-server.py de
make[1]: Entering directory '/workspace'
python3 -u api-server.py en
make[1]: Entering directory '/workspace'
python3 -u api-bridge.py
[api-bridge] running on :8080
LM: Failed to load.
LM: Failed to load.
Traceback (most recent call last):
  File "api-server.py", line 155, in <module>
Traceback (most recent call last):
  File "api-server.py", line 155, in <module>
        serve(args.lang)serve(args.lang)

  File "api-server.py", line 140, in serve
  File "api-server.py", line 140, in serve
        apg.add_ASRServicer_to_server(ASRServicer(lang), server)apg.add_ASRServicer_to_server(ASRServicer(lang), server)

  File "api-server.py", line 56, in __init__
  File "api-server.py", line 56, in __init__
    conf, lang, m, x_tfm, x_tfm_stream = load_stuff(lang)
    conf, lang, m, x_tfm, x_tfm_stream = load_stuff(lang)  File "/workspace/lib/inference.py", line 20, in load_stuff

  File "/workspace/lib/inference.py", line 20, in load_stuff
        conf, lang, m, tfms = parse_and_apply_config(inference=True, lang=lang)
conf, lang, m, tfms = parse_and_apply_config(inference=True, lang=lang)  File "/workspace/lib/config.py", line 151, in parse_and_apply_config

  File "/workspace/lib/config.py", line 151, in parse_and_apply_config
        load_asr_model(m, lang_name, lang, conf["cuda"]["device"], lm=lm)load_asr_model(m, lang_name, lang, conf["cuda"]["device"], lm=lm)

  File "/workspace/lib/model_utils.py", line 88, in load_asr_model
  File "/workspace/lib/model_utils.py", line 88, in load_asr_model
        model, {torch.nn.LSTM, torch.nn.Linear}, dtype=torch.qint8model, {torch.nn.LSTM, torch.nn.Linear}, dtype=torch.qint8

  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 285, in quantize_dynamic
  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 285, in quantize_dynamic
    convert(model, mapping, inplace=True)
  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 365, in convert
    convert(model, mapping, inplace=True)
  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 365, in convert
    convert(mod, mapping, inplace=True)
  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 365, in convert
    convert(mod, mapping, inplace=True)
  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 365, in convert
    convert(mod, mapping, inplace=True)
  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 365, in convert
    convert(mod, mapping, inplace=True)
  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 365, in convert
    convert(mod, mapping, inplace=True)
  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 366, in convert
    convert(mod, mapping, inplace=True)
  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 366, in convert
    reassign[name] = swap_module(mod, mapping)
  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 395, in swap_module
    reassign[name] = swap_module(mod, mapping)
  File "/usr/local/lib/python3.7/dist-packages/torch/quantization/quantize.py", line 395, in swap_module
    new_mod = mapping[type(mod)].from_float(mod)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/quantized/dynamic/modules/rnn.py", line 421, in from_float
    new_mod = mapping[type(mod)].from_float(mod)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/quantized/dynamic/modules/rnn.py", line 421, in from_float
        return super(LSTM, cls).from_float(mod)return super(LSTM, cls).from_float(mod)

  File "/usr/local/lib/python3.7/dist-packages/torch/nn/quantized/dynamic/modules/rnn.py", line 229, in from_float
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/quantized/dynamic/modules/rnn.py", line 229, in from_float
    mod.bias, mod.batch_first, mod.dropout, mod.bidirectional, dtype)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/quantized/dynamic/modules/rnn.py", line 335, in __init__
    mod.bias, mod.batch_first, mod.dropout, mod.bidirectional, dtype)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/quantized/dynamic/modules/rnn.py", line 335, in __init__
    super(LSTM, self).__init__('LSTM', *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/quantized/dynamic/modules/rnn.py", line 85, in __init__
    super(LSTM, self).__init__('LSTM', *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/quantized/dynamic/modules/rnn.py", line 85, in __init__
    torch.ops.quantized.linear_prepack(w_ih, b_ih)
RuntimeError: Didn't find engine for operation quantized::linear_prepack NoQEngine
    torch.ops.quantized.linear_prepack(w_ih, b_ih)
RuntimeError: Didn't find engine for operation quantized::linear_prepack NoQEngine
make[1]: *** [Makefile:55: sen] Error 1
make[1]: Leaving directory '/workspace'
make[1]: *** [Makefile:57: sde] Error 1
make[1]: Leaving directory '/workspace'
@iceychris
Copy link
Owner

Seems like PyTorch quantization is not supported for your platform.
I didn't have any issues on 64-bit linux with an Intel Processor.

Try applying this diff (git apply fix.diff):

diff --git a/lib/lm.py b/lib/lm.py
index ccb1b68..92f5117 100644
--- a/lib/lm.py
+++ b/lib/lm.py
@@ -90,9 +90,9 @@ def load_lm(conf, lang):
     lm.eval()

     # quantize
-    lm = torch.quantization.quantize_dynamic(
-        lm, {torch.nn.LSTM, torch.nn.Linear}, dtype=torch.qint8
-    )
+    # lm = torch.quantization.quantize_dynamic(
+    #     lm, {torch.nn.LSTM, torch.nn.Linear}, dtype=torch.qint8
+    # )
     lm.eval()

     return lm
diff --git a/lib/model_utils.py b/lib/model_utils.py
index e3b4139..461473e 100644
--- a/lib/model_utils.py
+++ b/lib/model_utils.py
@@ -84,8 +84,8 @@ def load_asr_model(
     # quantize model
     #  we need to this before loading our model
     #  as the saved model is quantized ???
-    model = torch.quantization.quantize_dynamic(
-        model, {torch.nn.LSTM, torch.nn.Linear}, dtype=torch.qint8
-    )
+    # model = torch.quantization.quantize_dynamic(
+    #     model, {torch.nn.LSTM, torch.nn.Linear}, dtype=torch.qint8
+    # )

     return model

and run this:

docker run -it -v $(pwd)/lib:/workspace/lib -p 8080:8080 iceychris/libreasr:latest

This will turn off quantization.

@rplevka
Copy link
Author

rplevka commented Nov 18, 2020

@iceychris thanks, that did the trick.
Right, it looks like my CPU is unable to do that..here's som CPU info for the record (in case you was interested):

$ cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz
stepping	: 9
microcode	: 0x21
cpu MHz		: 1399.993
cache size	: 3072 KB
physical id	: 0
siblings	: 4
core id		: 0
cpu cores	: 2
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts md_clear flush_l1d
vmx flags	: vnmi preemption_timer invvpid ept_x_only flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbds
bogomips	: 3592.15
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

processor	: 1
vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz
stepping	: 9
microcode	: 0x21
cpu MHz		: 1582.269
cache size	: 3072 KB
physical id	: 0
siblings	: 4
core id		: 0
cpu cores	: 2
apicid		: 1
initial apicid	: 1
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts md_clear flush_l1d
vmx flags	: vnmi preemption_timer invvpid ept_x_only flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbds
bogomips	: 3592.15
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

processor	: 2
vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz
stepping	: 9
microcode	: 0x21
cpu MHz		: 1339.551
cache size	: 3072 KB
physical id	: 0
siblings	: 4
core id		: 1
cpu cores	: 2
apicid		: 2
initial apicid	: 2
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts md_clear flush_l1d
vmx flags	: vnmi preemption_timer invvpid ept_x_only flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbds
bogomips	: 3592.15
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

processor	: 3
vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz
stepping	: 9
microcode	: 0x21
cpu MHz		: 1639.644
cache size	: 3072 KB
physical id	: 0
siblings	: 4
core id		: 1
cpu cores	: 2
apicid		: 3
initial apicid	: 3
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts md_clear flush_l1d
vmx flags	: vnmi preemption_timer invvpid ept_x_only flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbds
bogomips	: 3592.15
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

iceychris added a commit that referenced this issue Nov 21, 2020
@iceychris
Copy link
Owner

Your CPU looks good to me...
Closing this as I just pushed a fix that makes quantization optional by default.

@iceychris iceychris added this to Done in Roadmap Feb 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Development

No branches or pull requests

2 participants