Skip to content

OCR 失败:OCR API Error: 500 Internal Server Error #39

@GithubFeed

Description

@GithubFeed

MACOS 26.2 M5芯片,32G内存;

环境:

(deepseek-ocr-mlx) jat@192 DeepSeek-OCR-WebUI % ./verify_mac_env.sh
======================================
🔍 Verifying Mac Environment
======================================

✅ Conda environment: deepseek-ocr-mlx

🐍 Python 3.11.14

📦 Checking required packages...

  ✅ torch (2.9.1)
  ✅ torchvision (0.24.1)
  ✅ transformers (4.46.3)
  ✅ tokenizers (0.20.3)
  ✅ fastapi (0.104.1)
  ✅ uvicorn (0.24.0)
  ✅ fitz (1.26.7)
  ✅ PIL (12.1.0)
  ✅ einops (0.8.1)
  ✅ addict (2.4.0)
  ✅ easydict (N/A)
  ✅ matplotlib (3.10.8)
  ✅ numpy (1.26.4)

🍎 Checking MPS (Metal Performance Shaders)...
  ✅ MPS is available

======================================
✅ Environment verification passed!
   You can now run: ./start.sh
======================================
(deepseek-ocr-mlx) jat@192 DeepSeek-OCR-WebUI % 

手动下载模型:

https://huggingface.co/deepseek-ai/DeepSeek-OCR

设置本地模型并运行:

export LOCAL_MODEL_PATH=/Volumes/MacD/ai/Deepseek/DeepSeek-OCR-Model
python web_service_unified.py

前端报错:OCR服务正常,但是500报错:OCR 失败:OCR API Error: 500 Internal Server Error (

Image

后台日志:

         (deepseek-ocr-mlx) jat@192 ~ % cd /Volumes/MacD/ai/Deepseek/DeepSeek-OCR-WebUI
  (deepseek-ocr-mlx) jat@192 DeepSeek-OCR-WebUI % export LOCAL_MODEL_PATH=/Volumes/MacD/ai/Deepseek/DeepSeek-OCR-Model
  python web_service_unified.py
  
  ==================================================
  🚀 DeepSeek-OCR Unified Service
  ==================================================
  📍 URL: http://0.0.0.0:8001
  📚 Docs: http://0.0.0.0:8001/docs
  ==================================================
  
  INFO:     Started server process [11100]
  INFO:     Waiting for application startup.
  ==================================================
  🚀 DeepSeek-OCR Unified Service Starting...
  ==================================================
  📁 Using local model: /Volumes/MacD/ai/Deepseek/DeepSeek-OCR-Model
  ✅ Detected Apple Silicon with MPS support
  📦 Loading DeepSeek-OCR with MPS
  You are using a model of type deepseek_vl_v2 to instantiate a model of type DeepseekOCR. This is not supported for all configurations of models and can yield errors.
  Some weights of DeepseekOCRForCausalLM were not initialized from the model checkpoint at /Volumes/MacD/ai/Deepseek/DeepSeek-OCR-Model and are newly initialized: ['model.vision_model.embeddings.position_ids']
  You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
  ✅ Model loaded on mps
  ✅ Backend loaded: MPS
  ==================================================
  INFO:     Application startup complete.
  INFO:     Uvicorn running on http://0.0.0.0:8001 (Press CTRL+C to quit)
  INFO:     127.0.0.1:62478 - "GET /health HTTP/1.1" 200 OK
  /Users/jat/miniforge3/envs/deepseek-ocr-mlx/lib/python3.11/site-packages/torch/amp/autocast_mode.py:270: UserWarning: User provided device_type of 'cuda', but CUDA is not available. Disabling
    warnings.warn(
  ❌ Inference failed: Torch not compiled with CUDA enabled
  ❌ Error:
  Traceback (most recent call last):
    File "/Volumes/MacD/ai/Deepseek/DeepSeek-OCR-WebUI/web_service_unified.py", line 251, in ocr_endpoint
      text = backend.infer(prompt=prompt, image_path=tmp_file)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Volumes/MacD/ai/Deepseek/DeepSeek-OCR-WebUI/backends/mps_backend.py", line 47, in infer
      result = self.model.infer(
               ^^^^^^^^^^^^^^^^^
    File "/Users/jat/.cache/huggingface/modules/transformers_modules/DeepSeek-OCR-Model/modeling_deepseekocr.py", line 935, in infer
      input_ids.unsqueeze(0).cuda(),
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/jat/miniforge3/envs/deepseek-ocr-mlx/lib/python3.11/site-packages/torch/cuda/__init__.py", line 403, in _lazy_init
      raise AssertionError("Torch not compiled with CUDA enabled")
  AssertionError: Torch not compiled with CUDA enabled
  
  INFO:     127.0.0.1:62478 - "POST /ocr HTTP/1.1" 500 Internal Server Error
  INFO:     127.0.0.1:62478 - "GET /health HTTP/1.1" 200 OK
  ❌ Inference failed: Torch not compiled with CUDA enabled
  ❌ Error:
  Traceback (most recent call last):
    File "/Volumes/MacD/ai/Deepseek/DeepSeek-OCR-WebUI/web_service_unified.py", line 251, in ocr_endpoint
      text = backend.infer(prompt=prompt, image_path=tmp_file)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Volumes/MacD/ai/Deepseek/DeepSeek-OCR-WebUI/backends/mps_backend.py", line 47, in infer
      result = self.model.infer(
               ^^^^^^^^^^^^^^^^^
    File "/Users/jat/.cache/huggingface/modules/transformers_modules/DeepSeek-OCR-Model/modeling_deepseekocr.py", line 935, in infer
      input_ids.unsqueeze(0).cuda(),
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/jat/miniforge3/envs/deepseek-ocr-mlx/lib/python3.11/site-packages/torch/cuda/__init__.py", line 403, in _lazy_init
      raise AssertionError("Torch not compiled with CUDA enabled")
  AssertionError: Torch not compiled with CUDA enabled
  
  INFO:     127.0.0.1:62478 - "POST /ocr HTTP/1.1" 500 Internal Server Error
  ❌ Inference failed: Torch not compiled with CUDA enabled
  ❌ Error:
  Traceback (most recent call last):
    File "/Volumes/MacD/ai/Deepseek/DeepSeek-OCR-WebUI/web_service_unified.py", line 251, in ocr_endpoint
      text = backend.infer(prompt=prompt, image_path=tmp_file)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Volumes/MacD/ai/Deepseek/DeepSeek-OCR-WebUI/backends/mps_backend.py", line 47, in infer
      result = self.model.infer(
               ^^^^^^^^^^^^^^^^^
    File "/Users/jat/.cache/huggingface/modules/transformers_modules/DeepSeek-OCR-Model/modeling_deepseekocr.py", line 935, in infer
      input_ids.unsqueeze(0).cuda(),
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/jat/miniforge3/envs/deepseek-ocr-mlx/lib/python3.11/site-packages/torch/cuda/__init__.py", line 403, in _lazy_init
      raise AssertionError("Torch not compiled with CUDA enabled")
  AssertionError: Torch not compiled with CUDA enabled
  
  INFO:     127.0.0.1:62494 - "POST /ocr HTTP/1.1" 500 Internal Server Error
  ❌ Inference failed: Torch not compiled with CUDA enabled
  ❌ Error:
  Traceback (most recent call last):
    File "/Volumes/MacD/ai/Deepseek/DeepSeek-OCR-WebUI/web_service_unified.py", line 251, in ocr_endpoint
      text = backend.infer(prompt=prompt, image_path=tmp_file)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Volumes/MacD/ai/Deepseek/DeepSeek-OCR-WebUI/backends/mps_backend.py", line 47, in infer
      result = self.model.infer(
               ^^^^^^^^^^^^^^^^^
    File "/Users/jat/.cache/huggingface/modules/transformers_modules/DeepSeek-OCR-Model/modeling_deepseekocr.py", line 935, in infer
      input_ids.unsqueeze(0).cuda(),
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/jat/miniforge3/envs/deepseek-ocr-mlx/lib/python3.11/site-packages/torch/cuda/__init__.py", line 403, in _lazy_init
      raise AssertionError("Torch not compiled with CUDA enabled")
  AssertionError: Torch not compiled with CUDA enabled
  
  INFO:     127.0.0.1:62494 - "POST /ocr HTTP/1.1" 500 Internal Server Error
  INFO:     127.0.0.1:62494 - "GET /health HTTP/1.1" 200 OK
  INFO:     127.0.0.1:62498 - "GET /health HTTP/1.1" 200 OK
  INFO:     127.0.0.1:62502 - "GET /health HTTP/1.1" 200 OK
  INFO:     127.0.0.1:62503 - "GET /health HTTP/1.1" 200 OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions