From 129cfcd9f283dea0d64f2e20b77662febc2d802c Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期四, 23 三月 2023 10:01:32 +0800
Subject: [PATCH] cer tool
---
funasr/runtime/python/onnxruntime/rapid_paraformer/utils/utils.py | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/funasr/runtime/python/onnxruntime/rapid_paraformer/utils/utils.py b/funasr/runtime/python/onnxruntime/rapid_paraformer/utils/utils.py
index 8e220e0..2edde11 100644
--- a/funasr/runtime/python/onnxruntime/rapid_paraformer/utils/utils.py
+++ b/funasr/runtime/python/onnxruntime/rapid_paraformer/utils/utils.py
@@ -1,6 +1,5 @@
# -*- encoding: utf-8 -*-
-# @Author: SWHL
-# @Contact: liekkaskono@163.com
+
import functools
import logging
import pickle
@@ -147,8 +146,10 @@
class OrtInferSession():
- def __init__(self, model_file, device_id=-1):
+ def __init__(self, model_file, device_id=-1, intra_op_num_threads=4):
+ device_id = str(device_id)
sess_opt = SessionOptions()
+ sess_opt.intra_op_num_threads = intra_op_num_threads
sess_opt.log_severity_level = 4
sess_opt.enable_cpu_mem_arena = False
sess_opt.graph_optimization_level = GraphOptimizationLevel.ORT_ENABLE_ALL
@@ -166,7 +167,7 @@
}
EP_list = []
- if device_id != -1 and get_device() == 'GPU' \
+ if device_id != "-1" and get_device() == 'GPU' \
and cuda_ep in get_available_providers():
EP_list = [(cuda_ep, cuda_provider_options)]
EP_list.append((cpu_ep, cpu_provider_options))
@@ -176,7 +177,7 @@
sess_options=sess_opt,
providers=EP_list)
- if device_id != -1 and cuda_ep not in self.session.get_providers():
+ if device_id != "-1" and cuda_ep not in self.session.get_providers():
warnings.warn(f'{cuda_ep} is not avaiable for current env, the inference part is automatically shifted to be executed under {cpu_ep}.\n'
'Please ensure the installed onnxruntime-gpu version matches your cuda and cudnn version, '
'you can check their relations from the offical web site: '
--
Gitblit v1.9.1