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

export导出onnx运行出错 #185

Open
CYlcbw opened this issue Feb 14, 2025 · 0 comments
Open

export导出onnx运行出错 #185

CYlcbw opened this issue Feb 14, 2025 · 0 comments
Labels
question Further information is requested

Comments

@CYlcbw
Copy link

CYlcbw commented Feb 14, 2025

在使用export.py导出onnx的时候,在生成onnx的时候报错(提示在调用 embedding 时,有至少两个设备(cuda:0 和 cpu)存在不一致),请问有没有大佬知道怎么解决啊
具体报错是{(torch) root@mfkahpxnfnicaehc-snow-6c68c5f989-jvxzb:/data/coding/SenseVoice# python export.py
Downloading Model to directory: /root/.cache/modelscope/hub/iic/SenseVoiceSmall
2025-02-14 18:51:14,969 - modelscope - WARNING - Using branch: master as version is unstable, use with caution
Loading remote code successfully: model
Traceback (most recent call last):
File "/data/coding/SenseVoice/export.py", line 29, in
export_dir = export_utils.export(model=rebuilt_model, **kwargs)
File "/data/coding/SenseVoice/utils/export_utils.py", line 17, in export
_onnx(
File "/data/coding/SenseVoice/utils/export_utils.py", line 43, in _onnx
torch.onnx.export(
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/onnx/utils.py", line 516, in export
_export(
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/onnx/utils.py", line 1612, in _export
graph, params_dict, torch_out = _model_to_graph(
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/onnx/utils.py", line 1134, in _model_to_graph
graph, params, torch_out, module = _create_jit_graph(model, args)
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/onnx/utils.py", line 1010, in _create_jit_graph
graph, torch_out = _trace_and_get_graph_from_model(model, args)
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/onnx/utils.py", line 914, in _trace_and_get_graph_from_model
trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph(
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/jit/_trace.py", line 1310, in _get_trace_graph
outs = ONNXTracedModule(
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/jit/_trace.py", line 138, in forward
graph, out = torch._C._create_graph_by_tracing(
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/jit/_trace.py", line 129, in wrapper
outs.append(self.inner(*trace_inputs))
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1522, in _slow_forward
result = self.forward(*input, **kwargs)
File "/data/coding/SenseVoice/export_meta.py", line 32, in export_forward
language_query = self.embed(language.to(speech.device)).unsqueeze(1)
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1522, in _slow_forward
result = self.forward(*input, **kwargs)
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/nn/modules/sparse.py", line 163, in forward
return F.embedding(
File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/nn/functional.py", line 2264, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument index in method wrapper_CUDA__index_select)}

@CYlcbw CYlcbw added the question Further information is requested label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant