Răsfoiți Sursa

feat: 优化PP-StructureV3守护进程脚本,改进conda环境激活和错误提示

zhch158_admin 1 lună în urmă
părinte
comite
95d3c21cca
1 a modificat fișierele cu 36 adăugiri și 3 ștergeri
  1. 36 3
      zhch/ppstructure_v3_daemon.sh

+ 36 - 3
zhch/ppstructure_v3_daemon.sh

@@ -13,8 +13,19 @@ PORT="8111"
 DEVICE="gpu:3"
 PIPELINE_CONFIG="/home/ubuntu/zhch/PaddleX/zhch/my_config/PP-StructureV3.yaml"
 
-# 激活conda环境
-conda activate $CONDA_ENV
+# 正确初始化和激活conda环境
+# 方法1:使用conda.sh脚本初始化
+if [ -f "/home/ubuntu/anaconda3/etc/profile.d/conda.sh" ]; then
+    source /home/ubuntu/anaconda3/etc/profile.d/conda.sh
+    conda activate $CONDA_ENV
+elif [ -f "/opt/conda/etc/profile.d/conda.sh" ]; then
+    source /opt/conda/etc/profile.d/conda.sh
+    conda activate $CONDA_ENV
+else
+    # 方法2:直接使用conda可执行文件路径
+    echo "Warning: Using direct conda path activation"
+    export PATH="/home/ubuntu/anaconda3/envs/$CONDA_ENV/bin:$PATH"
+fi
 
 # 设置模型下载源(可选)
 export PADDLE_PDX_MODEL_SOURCE="bos"
@@ -35,6 +46,21 @@ start() {
         return 1
     fi
     
+    # 检查conda环境
+    if ! command -v python >/dev/null 2>&1; then
+        echo "❌ Python not found. Check conda environment activation."
+        return 1
+    fi
+    
+    # 检查paddlex命令
+    if ! command -v paddlex >/dev/null 2>&1; then
+        echo "❌ PaddleX not found. Check installation and environment."
+        return 1
+    fi
+    
+    echo "🔧 Using Python: $(which python)"
+    echo "🔧 Using PaddleX: $(which paddlex)"
+    
     # 启动PaddleX服务
     nohup paddlex --serve \
         --port $PORT \
@@ -135,13 +161,20 @@ config() {
     else
         echo "❌ Pipeline config file not found"
     fi
+    
+    # 显示环境信息
+    echo ""
+    echo "🔧 Environment:"
+    echo "  Python: $(which python 2>/dev/null || echo 'Not found')"
+    echo "  PaddleX: $(which paddlex 2>/dev/null || echo 'Not found')"
+    echo "  Conda: $(which conda 2>/dev/null || echo 'Not found')"
 }
 
 # 显示使用帮助
 usage() {
     echo "PaddleX PP-StructureV3 Service Daemon"
     echo "======================================"
-    echo "Usage: $0 {start|stop|restart|status|logs|test|config}"
+    echo "Usage: $0 {start|stop|restart|status|logs|config}"
     echo ""
     echo "Commands:"
     echo "  start   - Start the PaddleX service"