๐Ÿ“ ่พ“ๅ‡บ็›ฎๅฝ•: /home/songsenand/Project/SUimeModelTraner/exported_models ๐Ÿ“ฆ ๅŠ ่ฝฝcheckpoint: /home/songsenand/ไธ‹่ฝฝ/20260416best_model.pt Downloading Model from https://www.modelscope.cn to directory: /home/songsenand/.cache/modelscope/hub/models/iic/nlp_structbert_backbone_lite_std Loading weights: 0%| | 0/103 [00:00=18 to leverage latest ONNX features W0417 14:32:00.100000 710675 .venv/lib/python3.12/site-packages/torch/onnx/_internal/exporter/_registration.py:110] torchvision is not installed. Skipping torchvision::nms W0417 14:32:00.101000 710675 .venv/lib/python3.12/site-packages/torch/onnx/_internal/exporter/_registration.py:110] torchvision is not installed. Skipping torchvision::roi_align W0417 14:32:00.101000 710675 .venv/lib/python3.12/site-packages/torch/onnx/_internal/exporter/_registration.py:110] torchvision is not installed. Skipping torchvision::roi_pool /home/songsenand/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/lib/python3.12/contextlib.py:144: UserWarning: The tensor attributes self.pinyin_lstm._flat_weights[0], self.pinyin_lstm._flat_weights[1], self.pinyin_lstm._flat_weights[2], self.pinyin_lstm._flat_weights[3], self.pinyin_lstm._flat_weights[4], self.pinyin_lstm._flat_weights[5], self.pinyin_lstm._flat_weights[6], self.pinyin_lstm._flat_weights[7], self.pinyin_lstm._flat_weights[8], self.pinyin_lstm._flat_weights[9], self.pinyin_lstm._flat_weights[10], self.pinyin_lstm._flat_weights[11], self.pinyin_lstm._flat_weights[12], self.pinyin_lstm._flat_weights[13], self.pinyin_lstm._flat_weights[14], self.pinyin_lstm._flat_weights[15] were assigned during export. Such attributes must be registered as buffers using the `register_buffer` API (https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.register_buffer). next(self.gen) /home/songsenand/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/lib/python3.12/copyreg.py:99: FutureWarning: `isinstance(treespec, LeafSpec)` is deprecated, use `isinstance(treespec, TreeSpec) and treespec.is_leaf()` instead. return cls.__new__(cls, *args) The model version conversion is not supported by the onnxscript version converter and fallback is enabled. The model will be converted using the onnx C API (target version: 14). Failed to convert the model to the target version 14 using the ONNX C API. The model was not modified Traceback (most recent call last): File "/home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/onnxscript/version_converter/__init__.py", line 120, in call converted_proto = _c_api_utils.call_onnx_api( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/onnxscript/version_converter/_c_api_utils.py", line 65, in call_onnx_api result = func(proto) ^^^^^^^^^^^ File "/home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/onnxscript/version_converter/__init__.py", line 115, in _partial_convert_version return onnx.version_converter.convert_version( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/onnx/version_converter.py", line 39, in convert_version converted_model_str = C.convert_version(model_str, target_version) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: /github/workspace/onnx/version_converter/adapters/no_previous_version.h:24: adapt: Assertion `false` failed: No Previous Version of LayerNormalization exists /home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/torch/onnx/_internal/exporter/_onnx_program.py:487: UserWarning: # The axis name: batch_size will not be used, since it shares the same shape constraints with another axis: batch_size. rename_mapping = _dynamic_shapes.create_rename_mapping( /home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/torch/onnx/_internal/exporter/_onnx_program.py:487: UserWarning: # The axis name: seq_len will not be used, since it shares the same shape constraints with another axis: seq_len. rename_mapping = _dynamic_shapes.create_rename_mapping( /home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/torch/nn/modules/transformer.py:531: UserWarning: The PyTorch API of nested tensors is in prototype stage and will change in the near future. We recommend specifying layout=torch.jagged when constructing a nested tensor, as this layout receives active development, has better operator coverage, and works with torch.compile. (Triggered internally at /pytorch/aten/src/ATen/NestedTensorImpl.cpp:178.) output = torch._nested_tensor_from_mask( /home/songsenand/Project/SUimeModelTraner/export_onnx.py:155: UserWarning: # 'dynamic_axes' is not recommended when dynamo=True, and may lead to 'torch._dynamo.exc.UserError: Constraints violated.' Supply the 'dynamic_shapes' argument instead if export is unsuccessful. torch.onnx.export( W0417 14:32:05.304000 710675 .venv/lib/python3.12/site-packages/torch/onnx/_internal/exporter/_compat.py:133] Setting ONNX exporter to use operator set version 18 because the requested opset_version 14 is a lower version than we have implementations for. Automatic version conversion will be performed, which may not be successful at converting to the requested version. If version conversion is unsuccessful, the opset version of the exported model will be kept at 18. Please consider setting opset_version >=18 to leverage latest ONNX features W0417 14:32:05.492000 710675 .venv/lib/python3.12/site-packages/torch/onnx/_internal/exporter/_registration.py:110] torchvision is not installed. Skipping torchvision::nms W0417 14:32:05.492000 710675 .venv/lib/python3.12/site-packages/torch/onnx/_internal/exporter/_registration.py:110] torchvision is not installed. Skipping torchvision::roi_align W0417 14:32:05.492000 710675 .venv/lib/python3.12/site-packages/torch/onnx/_internal/exporter/_registration.py:110] torchvision is not installed. Skipping torchvision::roi_pool /home/songsenand/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/lib/python3.12/copyreg.py:99: FutureWarning: `isinstance(treespec, LeafSpec)` is deprecated, use `isinstance(treespec, TreeSpec) and treespec.is_leaf()` instead. return cls.__new__(cls, *args) The model version conversion is not supported by the onnxscript version converter and fallback is enabled. The model will be converted using the onnx C API (target version: 14). Failed to convert the model to the target version 14 using the ONNX C API. The model was not modified Traceback (most recent call last): File "/home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/onnxscript/version_converter/__init__.py", line 120, in call converted_proto = _c_api_utils.call_onnx_api( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/onnxscript/version_converter/_c_api_utils.py", line 65, in call_onnx_api result = func(proto) ^^^^^^^^^^^ File "/home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/onnxscript/version_converter/__init__.py", line 115, in _partial_convert_version return onnx.version_converter.convert_version( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/onnx/version_converter.py", line 39, in convert_version converted_model_str = C.convert_version(model_str, target_version) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: /github/workspace/onnx/version_converter/adapters/no_previous_version.h:24: adapt: Assertion `false` failed: No Previous Version of LayerNormalization exists /home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/torch/onnx/_internal/exporter/_onnx_program.py:487: UserWarning: # The axis name: batch_size will not be used, since it shares the same shape constraints with another axis: batch_size. rename_mapping = _dynamic_shapes.create_rename_mapping( /home/songsenand/Project/SUimeModelTraner/.venv/lib/python3.12/site-packages/torch/onnx/_internal/exporter/_onnx_program.py:487: UserWarning: # The axis name: seq_len will not be used, since it shares the same shape constraints with another axis: seq_len. rename_mapping = _dynamic_shapes.create_rename_mapping( ๐Ÿ“Š ๆจกๅž‹้…็ฝฎ: {'learning_rate': 1e-06, 'weight_decay': 0.05, 'warmup_ratio': 0.1, 'label_smoothing': 0.1, 'total_steps': 781250} ๆญฃๅœจๅฏผๅ‡บไธŠไธ‹ๆ–‡็ผ–็ ๅ™จๅˆฐ: exported_models/context_encoder.onnx Applied 77 of general pattern rewrite rules. โœ… ไธŠไธ‹ๆ–‡็ผ–็ ๅ™จๅฏผๅ‡บๅฎŒๆˆ โœ… ONNXๆจกๅž‹้ชŒ่ฏ้€š่ฟ‡ ๆญฃๅœจๅฏผ่งฃ็ ๅ™จๅˆฐ: exported_models/decoder.onnx Applied 21 of general pattern rewrite rules. โœ… ่งฃ็ ๅ™จๅฏผๅ‡บๅฎŒๆˆ โœ… ONNXๆจกๅž‹้ชŒ่ฏ้€š่ฟ‡ โœ… ็คบไพ‹่พ“ๅ…ฅๅทฒไฟๅญ˜ๅˆฐ: exported_models/example_inputs.npz โœ… PyTorch็คบไพ‹่พ“ๅ…ฅๅทฒไฟๅญ˜ๅˆฐ: exported_models/example_inputs.pt โœ… ๆŽจ็†็คบไพ‹่„šๆœฌๅทฒไฟๅญ˜ๅˆฐ: exported_models/inference_example.py ============================================================ ๐ŸŽ‰ ONNXๅฏผๅ‡บๅฎŒๆˆ๏ผ ============================================================ ็”Ÿๆˆ็š„ๆจกๅž‹ๆ–‡ไปถ: - exported_models/context_encoder.onnx - exported_models/decoder.onnx - exported_models/example_inputs.npz - exported_models/example_inputs.pt - exported_models/inference_example.py ไฝฟ็”จๆ–นๆณ•: 1. ๆฃ€ๆŸฅๆจกๅž‹: python -m onnx.checker exported_models/context_encoder.onnx 2. ่ฟ่กŒๆŽจ็†็คบไพ‹: cd exported_models && python inference_example.py 3. ้›†ๆˆๅˆฐๆ‚จ็š„ๅบ”็”จ: ๅ‚่€ƒinference_example.pyไธญ็š„ONNXInference็ฑป ๆณจๆ„: - ่ฏท็กฎไฟๅฎ‰่ฃ…ไบ†onnxruntime: pip install onnxruntime - GPUๆŽจ็†้œ€่ฆonnxruntime-gpu: pip install onnxruntime-gpu - ๆŸๆœ็ดข็ฎ—ๆณ•้œ€่ฆๆ นๆฎๅฎž้™…้œ€ๆฑ‚่ฟ›่กŒ่ฐƒๆ•ด