set max threads of numexpr to improve performance and ommit warnings

This commit is contained in:
liunux4odoo 2023-08-24 11:04:30 +08:00
parent 3504cb5274
commit 4899c3b3cc
1 changed files with 8 additions and 0 deletions

View File

@ -5,6 +5,14 @@ import sys
import os
from pprint import pprint
# 设置numexpr最大线程数默认为CPU核心数
try:
import numexpr
n_cores = numexpr.utils.detect_number_of_cores()
os.environ["NUMEXPR_MAX_THREADS"] = str(n_cores)
except:
pass
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
from configs.model_config import EMBEDDING_DEVICE, EMBEDDING_MODEL, llm_model_dict, LLM_MODEL, LLM_DEVICE, LOG_PATH, \
logger