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

新增調用 GPU 推理功能 #22

Open
bensonbs opened this issue Jan 23, 2024 · 0 comments
Open

新增調用 GPU 推理功能 #22

bensonbs opened this issue Jan 23, 2024 · 0 comments

Comments

@bensonbs
Copy link

調用 GPU 推理功能

測試以下作法能夠成功調用GPU推理

使用 onnxruntime gpu版本

pip install onnxruntime-gpu

測試是否安裝成功

import onnxruntime
print(onnxruntime.get_device())
GPU

測試是否調用成功

ort_session = onnxruntime.InferenceSession("./G2PWModel-v2-onnx/g2pw.onnx",providers=['CUDAExecutionProvider'])
print(ort_session.get_providers())
['CUDAExecutionProvider', 'CPUExecutionProvider']

理論上只須修改此行

self.session_g2pw = onnxruntime.InferenceSession(os.path.join(model_dir, 'g2pw.onnx'), sess_options=sess_options)

self.session_g2pw =  onnxruntime.InferenceSession(os.path.join(model_dir, 'g2pw.onnx'), sess_options=sess_options,providers=['CUDAExecutionProvider'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant