1
框架组件
提问帖
新人贴
Z100使用torch 2.1.0版本推理时报错,RuntimeError: USE_MEMEFF_ATTENTION was not enabled for build. 导致无法使用torch的nn.TransformerEncoderLayer
2026-01-21 17:37:38
65

/usr/local/lib/python3.10/dist-packages/pick/torchtext/data/field.py:151: UserWarning: Field class will be retired soon and moved to torchtext.legacy. Please see the most recent release notes for further information.

warnings.warn('{} class will be retired soon and moved to torchtext.legacy. Please see the most recent release notes for further information.'.format(self.__class__.__name__), UserWarning)

get hyhal driver version error, open file(/sys/module/hydcu/version and /sys/module/amdgpu/version) error, skip init hydmi

/usr/local/lib/python3.10/dist-packages/torch/nn/modules/transformer.py:282: UserWarning: enable_nested_tensor is True, but self.use_nested_tensor is False because encoder_layer.self_attn.batch_first was not True(use batch_first for better inference performance)

warnings.warn(f"enable_nested_tensor is True, but self.use_nested_tensor is False because {why_not_sparsity_fast_path}")

/usr/local/lib/python3.10/dist-packages/pick/torchtext/data/field.py:37: UserWarning: RawField class will be retired soon and moved to torchtext.legacy. Please see the most recent release notes for further information.

warnings.warn('{} class will be retired soon and moved to torchtext.legacy. Please see the most recent release notes for further information.'.format(self.__class__.__name__), UserWarning)

Launch params (512, 1, 1) are larger than launch bounds (256) for kernel _ZN6vision3ops12_GLOBAL__N_129roi_align_forward_kernel_implIfEEviPKT_S3_iiiiiibS5_PS3_ please add __launch_bounds__ to kernel define or use --gpu-max-threads-per-block recompile program !

Traceback (most recent call last):

File "/data/models/test.py", line 20, in <module>

results = api.predict(ocr_text, bytes)

File "/usr/local/lib/python3.10/dist-packages/pick/pick_api/api.py", line 111, in predict

output = self.pick_model(**document)

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl

return self._call_impl(*args, **kwargs)

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl

return forward_call(*args, **kwargs)

File "/usr/local/lib/python3.10/dist-packages/pick/model/pick.py", line 137, in forward

x = self.encoder(images=whole_image, boxes_coordinate=boxes_coordinate, transcripts=text_emb,

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl

return self._call_impl(*args, **kwargs)

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl

return forward_call(*args, **kwargs)

File "/usr/local/lib/python3.10/dist-packages/pick/model/encoder.py", line 172, in forward

out = self.transformer_encoder(

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl

return self._call_impl(*args, **kwargs)

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl

return forward_call(*args, **kwargs)

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/transformer.py", line 387, in forward

output = mod(output, src_mask=mask, is_causal=is_causal, src_key_padding_mask=src_key_padding_mask_for_layers)

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl

return self._call_impl(*args, **kwargs)

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl

return forward_call(*args, **kwargs)

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/transformer.py", line 707, in forward

x = self.norm1(x + self._sa_block(x, src_mask, src_key_padding_mask, is_causal=is_causal))

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/transformer.py", line 715, in _sa_block

x = self.self_attn(x, x, x,

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl

return self._call_impl(*args, **kwargs)

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl

return forward_call(*args, **kwargs)

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/activation.py", line 1241, in forward

attn_output, attn_output_weights = F.multi_head_attention_forward(

File "/usr/local/lib/python3.10/dist-packages/torch/nn/functional.py", line 5687, in multi_head_attention_forward

attn_output = scaled_dot_product_attention(q, k, v, attn_mask, dropout_p, is_causal)

RuntimeError: USE_MEMEFF_ATTENTION was not enabled for build.

全部评论(2)
只看楼主
潘
潘洪岩
楼主
2楼
K100_AI 推理正常,可以输出结果:
/usr/local/lib/python3.10/dist-packages/pick/torchtext/data/field.py:151: UserWarning: Field class will be retired soon and moved to torchtext.legacy. Please see the most recent release notes for further information.
  warnings.warn('{} class will be retired soon and moved to torchtext.legacy. Please see the most recent release notes for further information.'.format(self.__class__.__name__), UserWarning)
get hyhal driver version error, open file(/sys/module/hydcu/version and /sys/module/amdgpu/version) error, skip init hydmi
/usr/local/lib/python3.10/dist-packages/torch/nn/modules/transformer.py:282: UserWarning: enable_nested_tensor is True, but self.use_nested_tensor is False because encoder_layer.self_attn.batch_first was not True(use batch_first for better inference performance)
  warnings.warn(f"enable_nested_tensor is True, but self.use_nested_tensor is False because {why_not_sparsity_fast_path}")
/usr/local/lib/python3.10/dist-packages/pick/torchtext/data/field.py:37: UserWarning: RawField class will be retired soon and moved to torchtext.legacy. Please see the most recent release notes for further information.
  warnings.warn('{} class will be retired soon and moved to torchtext.legacy. Please see the most recent release notes for further information.'.format(self.__class__.__name__), UserWarning)
Launch params (512, 1, 1) are larger than launch bounds (256) for kernel _ZN6vision3ops12_GLOBAL__N_129roi_align_forward_kernel_implIfEEviPKT_S3_iiiiiibS5_PS3_ please add __launch_bounds__ to kernel define or use --gpu-max-threads-per-block recompile program !
15.32581615447998
0.5495152473449707
0.33722448348999023
0.48068761825561523
[{'entity_name': 'id', 'text': '海关编号: 096020210000009288'}, {'entity_name': 'page', 'text': '页码/页数:1/1'}, {'entity_name': 'consignor', 'text': '吉林依华渔具腔份有限公司'}, {'entity_name': 'declareDate', 'text': '20210617'}, {'entity_name': 'transportMode', 'text': '水路运输'}, {'entity_name': 'deliveryNumbers', 'text': 'DIFC21E3243217'}, {'entity_name': 'partten', 'text': '监管方式 (0110)'}, {'entity_name': 'tradeRegion', 'text': '韩'}, {'entity_name': 'contractNumbers', 'text': 'EH-210601'}, {'entity_name': 'tradeRegion', 'text': '韩国'}, {'entity_name': 'grossAmount', 'text': '72'}, {'entity_name': 'grossWeight', 'text': '1372. 19'}, {'entity_name': 'tradeTerms', 'text': 'FOB'}, {'entity_name': 'remark', 'text': '备注:N/M 集装箱标箱数及号码: 2;DDFU4000292;'}, {'entity_name': 'num', 'text': '1'}, {'entity_name': 'name', 'text': '9507100090 碳纤维钓鱼竿'}, {'entity_name': 'weight1', 'text': '27.'}, {'entity_name': 'weight1', 'text': '2'}, {'entity_name': 'weight2', 'text': '1333.26千克'}, {'entity_name': 'totalPrice', 'text': '58145. 06'}, {'entity_name': 'weight3', 'text': '2113副'}, {'entity_name': 'currency', 'text': '美元'}, {'entity_name': 'num', 'text': '2'}, {'entity_name': 'name', 'text': '9507100090 鱼竿竿节'}, {'entity_name': 'weight1', 'text': '1726副'}, {'entity_name': 'weight2', 'text': '25.93千克'}, {'entity_name': 'totalPrice', 'text': '4340. 71'}, {'entity_name': 'weight3', 'text': '1726副'}, {'entity_name': 'currency', 'text': '美元'}, {'entity_name': 'num', 'text': '3'}, {'entity_name': 'name', 'text': '3921199090 海绵'}, {'entity_name': 'weight1', 'text': '13 千克'}, {'entity_name': 'totalPrice', 'text': '420. 00'}, {'entity_name': 'weight3', 'text': '1000 个'}, {'entity_name': 'currency', 'text': '美元'}]
1/21
潘
潘洪岩
楼主
1楼
环境:Driver Version: 5.15.0-143-generic;DTK 24.04.3
1/21
没有更多内容了
--
楼主
Level.6
0 帖子
楼主热帖
暂无数据