OCR 修复:无 cuDNN 用 CPU、禁用 ir_optim 避免 SIGILL。

This commit is contained in:
dekun
2026-06-28 15:18:42 +08:00
parent 0d4861fa62
commit 035b65dcc8
3 changed files with 39 additions and 23 deletions
+30 -4
View File
@@ -7,6 +7,28 @@ ocr_worker_dir() {
echo "${INSTALL_DIR}/deploy/ocr-worker"
}
detect_ocr_use_gpu() {
if [[ "${OCR_USE_GPU:-auto}" == "false" ]]; then
echo "false"
return
fi
if [[ "${OCR_USE_GPU:-auto}" == "true" ]]; then
if ldconfig -p 2>/dev/null | grep -q libcudnn; then
echo "true"
else
log_warn "未检测到 cuDNN 库,GPU OCR 不可用,改用 CPU"
echo "false"
fi
return
fi
# auto
if command -v nvidia-smi >/dev/null && ldconfig -p 2>/dev/null | grep -q libcudnn; then
echo "true"
else
echo "false"
fi
}
install_ocr_worker() {
local worker_dir
worker_dir="$(ocr_worker_dir)"
@@ -14,9 +36,11 @@ install_ocr_worker() {
log_error "未找到 ${worker_dir}"
return 1
fi
log_info "安装/更新 OCR Worker (PaddleOCR GPU)…"
log_info "安装/更新 OCR Worker (PaddleOCR)…"
chmod +x "${worker_dir}"/*.sh 2>/dev/null || true
OCR_PORT="${OCR_PORT}" bash "${worker_dir}/install.sh"
local use_gpu
use_gpu="$(detect_ocr_use_gpu)"
OCR_PORT="${OCR_PORT}" OCR_USE_GPU="${use_gpu}" bash "${worker_dir}/install.sh"
}
ocr_screen_running() {
@@ -35,7 +59,9 @@ start_ocr_screen() {
return 1
fi
log_info "启动 OCR Worker → screen 会话「${OCR_SCREEN_NAME}」(GPU 常驻, 端口 ${OCR_PORT})"
local use_gpu log_file
use_gpu="$(detect_ocr_use_gpu)"
log_info "启动 OCR Worker → screen「${OCR_SCREEN_NAME}」(GPU=${use_gpu}, 端口 ${OCR_PORT})"
if ocr_screen_running; then
screen -S "${OCR_SCREEN_NAME}" -X quit 2>/dev/null || true
sleep 1
@@ -46,7 +72,7 @@ start_ocr_screen() {
screen -dmS "${OCR_SCREEN_NAME}" bash -c "
cd '${worker_dir}' &&
export OCR_USE_GPU=true OCR_PORT='${OCR_PORT}' OCR_HOST=0.0.0.0 &&
export OCR_USE_GPU='${use_gpu}' OCR_PORT='${OCR_PORT}' OCR_HOST=0.0.0.0 &&
exec bash run.sh >> '${log_file}' 2>&1
"
sleep 2