marcosremar2 commited on
Commit
db349b0
·
1 Parent(s): 93b7887

Fix: Make entrypoint.sh handle missing nvidia-smi gracefully and switch to CPU hardware

Browse files
Files changed (2) hide show
  1. entrypoint.sh +21 -2
  2. space_config.json +1 -1
entrypoint.sh CHANGED
@@ -6,7 +6,19 @@ source /opt/mineru_venv/bin/activate
6
 
7
  # Display GPU information
8
  echo "Checking NVIDIA GPU status:"
9
- nvidia-smi
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  # Display MinerU version
12
  echo "MinerU version:"
@@ -57,9 +69,16 @@ CONFIG_DIR="$HOME/.config/magic_pdf"
57
  mkdir -p "$CONFIG_DIR"
58
  if [ ! -f "$CONFIG_DIR/magic-pdf.json" ]; then
59
  echo "Creating magic-pdf.json configuration file..."
 
 
 
 
 
 
 
60
  cat > "$CONFIG_DIR/magic-pdf.json" << EOF
61
  {
62
- "device-mode": "gpu",
63
  "layout-config": {
64
  "model": "doclayout_yolo",
65
  "enable": true
 
6
 
7
  # Display GPU information
8
  echo "Checking NVIDIA GPU status:"
9
+ if command -v nvidia-smi &> /dev/null; then
10
+ nvidia-smi
11
+ else
12
+ echo "nvidia-smi command not found. GPU may not be available or drivers not installed."
13
+ echo "Continuing with CPU mode..."
14
+
15
+ # Update the magic-pdf config to use CPU mode if GPU is not available
16
+ CONFIG_DIR="$HOME/.config/magic_pdf"
17
+ mkdir -p "$CONFIG_DIR"
18
+ if [ -f "$CONFIG_DIR/magic-pdf.json" ]; then
19
+ sed -i 's/"device-mode": "gpu"/"device-mode": "cpu"/g' "$CONFIG_DIR/magic-pdf.json" || true
20
+ fi
21
+ fi
22
 
23
  # Display MinerU version
24
  echo "MinerU version:"
 
69
  mkdir -p "$CONFIG_DIR"
70
  if [ ! -f "$CONFIG_DIR/magic-pdf.json" ]; then
71
  echo "Creating magic-pdf.json configuration file..."
72
+ # Check if GPU is available to determine default mode
73
+ if command -v nvidia-smi &> /dev/null; then
74
+ DEVICE_MODE="gpu"
75
+ else
76
+ DEVICE_MODE="cpu"
77
+ fi
78
+
79
  cat > "$CONFIG_DIR/magic-pdf.json" << EOF
80
  {
81
+ "device-mode": "$DEVICE_MODE",
82
  "layout-config": {
83
  "model": "doclayout_yolo",
84
  "enable": true
space_config.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
  "runtime": "docker",
3
- "hardware": "nvidia-l4-1x-16gb"
4
  }
 
1
  {
2
  "runtime": "docker",
3
+ "hardware": "cpu"
4
  }