MollySophia / rwkv-qualcomm

Inference rwkv5 or rwkv6 with Qualcomm AI Engine Direct SDK
37 stars 3 forks source link

当我使用covert_model.py转换模型时出现错误 #6

Closed guoguo1314 closed 2 hours ago

guoguo1314 commented 3 hours ago
Traceback (most recent call last):
  File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 495, in <module>
    main()
  File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 489, in main
    result = generator.build_targets(config)
  File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 393, in build_targets
    self._normalize_config(config)
  File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 361, in _normalize_config
    raise FileNotFoundError(f'Unable to find the model source file, invalid path: {config.model_cpp.absolute()}')
FileNotFoundError: Unable to find the model source file, invalid path: /home/lyg/Codes/rwkv-qualcomm/onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4.cpp

qnn:2.26.0.240828 看样子是没有生成对应的cpp文件。

MollySophia commented 2 hours ago

看起来是的,请问有没有完整的日志?

guoguo1314 commented 2 hours ago

有,来了。 (rwkv-qcm) (base) lyg@lyg-System-Product-Name:~/Codes/rwkv-qualcomm$ python convert_model.py /home/lyg/Pth/Rwkv/Rwkv-6-world-1.6b/RWKV-x060-World-1B6-v2.1-20240328-ctx4096.pth --chunks 4 /home/lyg/Codes/rwkv-qualcomm/rwkv_src/rwkv_model.py:80: FutureWarning: You are using torch.load with weights_only=False (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only will be flipped to True. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. w = torch.load(args.MODEL_NAME + '.pth', map_location='cpu') Model version: 6 n_layer: 24 n_embd: 2048 vocab_size: 65536 n_att: 2048 n_ffn: 7168 Chunk 0: layers 0 to 6 Chunk 1: layers 6 to 12 Chunk 2: layers 12 to 18 Chunk 3: layers 18 to 24 /home/lyg/Codes/rwkv-qualcomm/rwkv_src/rwkv_v6_modules.py:111: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! assert batch_size == 1 /home/lyg/Codes/rwkv-qualcomm/rwkv_src/rwkv_v6_modules.py:112: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! if seq_length == 1: /home/lyg/Codes/rwkv-qualcomm/rwkv_src/rwkv_v6_modules.py:155: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! if seq_length == 1: /home/lyg/Codes/rwkv-qualcomm/rwkv_src/rwkv_v6_modules.py:220: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! assert batch_size == 1 /home/lyg/Codes/rwkv-qualcomm/rwkv_src/rwkv_v6_modules.py:221: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! if seq_length == 1: onnx model chunk0 saved to onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4.onnx onnx model chunk1 saved to onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk2of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk2of4.onnx onnx model chunk2 saved to onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk3of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk3of4.onnx onnx model chunk3 saved to onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4.onnx Converting and compiling QNN models... /opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter -i onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4.onnx --float_bw 32 --input_layout "state1_in" "NFC" --input_layout "state4_in" "NFC" --input_layout "state7_in" "NFC" --input_layout "state10_in" "NFC" --input_layout "state13_in" "NFC" --input_layout "state16_in" "NFC" --input_layout "in" "NFC" Traceback (most recent call last): File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter", line 12, in from qti.aisw.converters import onnx as onnx_frontend ModuleNotFoundError: No module named 'qti' Compiling QNN model library... 2024-11-15 16:04:35,022 - INFO - qnn-model-lib-generator: Model cpp file path : onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4.cpp 2024-11-15 16:04:35,022 - INFO - qnn-model-lib-generator: Model bin file path : onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4.bin 2024-11-15 16:04:35,022 - INFO - qnn-model-lib-generator: Library target : [['x86_64-linux-clang', 'aarch64-android']] 2024-11-15 16:04:35,022 - INFO - qnn-model-lib-generator: Library name : RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4 2024-11-15 16:04:35,022 - INFO - qnn-model-lib-generator: Output directory : /home/lyg/Codes/rwkv-qualcomm/lib Traceback (most recent call last): File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 495, in main() File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 489, in main result = generator.build_targets(config) File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 393, in build_targets self._normalize_config(config) File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 367, in _normalize_config raise FileNotFoundError(f'Unable to find the bin file, invalid path: {config.model_bin.absolute()}') FileNotFoundError: Unable to find the bin file, invalid path: /home/lyg/Codes/rwkv-qualcomm/onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4.bin /opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter -i onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk2of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk2of4.onnx --float_bw 32 --input_layout "state19_in" "NFC" --input_layout "state22_in" "NFC" --input_layout "state25_in" "NFC" --input_layout "state28_in" "NFC" --input_layout "state31_in" "NFC" --input_layout "state34_in" "NFC" --input_layout "in" "NFC" Traceback (most recent call last): File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter", line 12, in from qti.aisw.converters import onnx as onnx_frontend ModuleNotFoundError: No module named 'qti' Compiling QNN model library... 2024-11-15 16:04:35,077 - INFO - qnn-model-lib-generator: Model cpp file path : onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk2of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk2of4.cpp 2024-11-15 16:04:35,077 - INFO - qnn-model-lib-generator: Model bin file path : onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk2of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk2of4.bin 2024-11-15 16:04:35,077 - INFO - qnn-model-lib-generator: Library target : [['x86_64-linux-clang', 'aarch64-android']] 2024-11-15 16:04:35,077 - INFO - qnn-model-lib-generator: Library name : RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk2of4 2024-11-15 16:04:35,077 - INFO - qnn-model-lib-generator: Output directory : /home/lyg/Codes/rwkv-qualcomm/lib Traceback (most recent call last): File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 495, in main() File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 489, in main result = generator.build_targets(config) File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 393, in build_targets self._normalize_config(config) File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 361, in _normalize_config raise FileNotFoundError(f'Unable to find the model source file, invalid path: {config.model_cpp.absolute()}') FileNotFoundError: Unable to find the model source file, invalid path: /home/lyg/Codes/rwkv-qualcomm/onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk2of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk2of4.cpp /opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter -i onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk3of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk3of4.onnx --float_bw 32 --input_layout "state37_in" "NFC" --input_layout "state40_in" "NFC" --input_layout "state43_in" "NFC" --input_layout "state46_in" "NFC" --input_layout "state49_in" "NFC" --input_layout "state52_in" "NFC" --input_layout "in" "NFC" Traceback (most recent call last): File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter", line 12, in from qti.aisw.converters import onnx as onnx_frontend ModuleNotFoundError: No module named 'qti' Compiling QNN model library... 2024-11-15 16:04:35,130 - INFO - qnn-model-lib-generator: Model cpp file path : onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk3of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk3of4.cpp 2024-11-15 16:04:35,130 - INFO - qnn-model-lib-generator: Model bin file path : onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk3of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk3of4.bin 2024-11-15 16:04:35,130 - INFO - qnn-model-lib-generator: Library target : [['aarch64-android', 'x86_64-linux-clang']] 2024-11-15 16:04:35,130 - INFO - qnn-model-lib-generator: Library name : RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk3of4 2024-11-15 16:04:35,130 - INFO - qnn-model-lib-generator: Output directory : /home/lyg/Codes/rwkv-qualcomm/lib Traceback (most recent call last): File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 495, in main() File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 489, in main result = generator.build_targets(config) File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 393, in build_targets self._normalize_config(config) File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 361, in _normalize_config raise FileNotFoundError(f'Unable to find the model source file, invalid path: {config.model_cpp.absolute()}') FileNotFoundError: Unable to find the model source file, invalid path: /home/lyg/Codes/rwkv-qualcomm/onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk3of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk3of4.cpp /opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter -i onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4.onnx --float_bw 32 --input_layout "state55_in" "NFC" --input_layout "state58_in" "NFC" --input_layout "state61_in" "NFC" --input_layout "state64_in" "NFC" --input_layout "state67_in" "NFC" --input_layout "state70_in" "NFC" --input_layout "in" "NFC" Traceback (most recent call last): File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter", line 12, in from qti.aisw.converters import onnx as onnx_frontend ModuleNotFoundError: No module named 'qti' Compiling QNN model library... 2024-11-15 16:04:35,191 - INFO - qnn-model-lib-generator: Model cpp file path : onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4.cpp 2024-11-15 16:04:35,191 - INFO - qnn-model-lib-generator: Model bin file path : onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4.bin 2024-11-15 16:04:35,191 - INFO - qnn-model-lib-generator: Library target : [['x86_64-linux-clang', 'aarch64-android']] 2024-11-15 16:04:35,191 - INFO - qnn-model-lib-generator: Library name : RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4 2024-11-15 16:04:35,191 - INFO - qnn-model-lib-generator: Output directory : /home/lyg/Codes/rwkv-qualcomm/lib Traceback (most recent call last): File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 495, in main() File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 489, in main result = generator.build_targets(config) File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 393, in build_targets self._normalize_config(config) File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-model-lib-generator", line 361, in _normalize_config raise FileNotFoundError(f'Unable to find the model source file, invalid path: {config.model_cpp.absolute()}') FileNotFoundError: Unable to find the model source file, invalid path: /home/lyg/Codes/rwkv-qualcomm/onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk4of4.cpp

MollySophia commented 2 hours ago

Converting and compiling QNN models... /opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter -i onnx/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4/RWKV-x060-World-1B6-v2.1-20240328-ctx4096_chunk1of4.onnx --float_bw 32 --input_layout "state1_in" "NFC" --input_layout "state4_in" "NFC" --input_layout "state7_in" "NFC" --input_layout "state10_in" "NFC" --input_layout "state13_in" "NFC" --input_layout "state16_in" "NFC" --input_layout "in" "NFC" Traceback (most recent call last): File "/opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter", line 12, in from qti.aisw.converters import onnx as onnx_frontend ModuleNotFoundError: No module named 'qti' Compiling QNN model library...

看起来好像是qairt的环境没装好

guoguo1314 commented 2 hours ago

是装好了qnn的,是qnn的头文件问题,要在 /opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter.py 添加 sys.path.append('/opt/qcom/aistack/qairt/2.26.0.240828/lib/python') 要不然python解释器找不到路径。 谢谢老哥。

MollySophia commented 2 hours ago

是装好了qnn的,是qnn的头文件问题,要在 /opt/qcom/aistack/qairt/2.26.0.240828/bin/x86_64-linux-clang/qnn-onnx-converter.py 添加 sys.path.append('/opt/qcom/aistack/qairt/2.26.0.240828/lib/python') 要不然python解释器找不到路径。 谢谢老哥。

这么说来,是不是没有执行source ${QNN_SDK_ROOT}/bin/envsetup.sh

guoguo1314 commented 2 hours ago

没有执行source ${QNN_SDK_ROOT}/bin/envsetup.sh,只是export了,export QNN_SDK_ROOT=/opt/qcom/aistack/qairt/2.26.0.240828。

MollySophia commented 2 hours ago

没有执行source ${QNN_SDK_ROOT}/bin/envsetup.sh,只是export了,export QNN_SDK_ROOT=/opt/qcom/aistack/qairt/2.26.0.240828。

https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/setup.html?product=1601111740009302#environment-setup

guoguo1314 commented 2 hours ago

好的,谢谢老哥