Skip to content

[macOS Apple Silicon] Startup fails without PyTorch and Accelerate, and requires manual frontend build #42

@niccoreyes

Description

@niccoreyes

I had the same issue, I had to install pytorch for Apple Silicon:

from

~/Github/DeepSeek-OCR-WebUI main ❯ ./start.sh                                                          1m 17s  deepseek-ocr
==========================================
🚀 DeepSeek-OCR-WebUI Startup
==========================================
🍎 Running on macOS
   Apple Silicon detected
   Selected backend: mps
==========================================
⚠️  Conda environment 'deepseek-ocr-mlx' not found
   Running with system Python

==================================================
🚀 DeepSeek-OCR Unified Service
==================================================
📍 URL: http://0.0.0.0:8001
📚 Docs: http://0.0.0.0:8001/docs
==================================================

INFO:     Started server process [14683]
INFO:     Waiting for application startup.
==================================================
🚀 DeepSeek-OCR Unified Service Starting...
==================================================
🔧 Forced backend: MPS
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
ERROR:    Traceback (most recent call last):
  File "/Users/niccoreyes/miniconda3/envs/deepseek-ocr/lib/python3.11/site-packages/starlette/routing.py", line 677, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/Users/niccoreyes/miniconda3/envs/deepseek-ocr/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/niccoreyes/Github/DeepSeek-OCR-WebUI/web_service_unified.py", line 209, in lifespan
    from backends.mps_backend import MPSBackend
  File "/Users/niccoreyes/Github/DeepSeek-OCR-WebUI/backends/mps_backend.py", line 4, in <module>
    import torch
ModuleNotFoundError: No module named 'torch'

ERROR:    Application startup failed. Exiting.

then

conda install pytorch torchvision torchaudio -c pytorch-nightly

After installing pytorch, I encountered:

~/Github/DeepSeek-OCR-WebUI main ❯ ./start.sh                                                                  deepseek-ocr
==========================================
🚀 DeepSeek-OCR-WebUI Startup
==========================================
🍎 Running on macOS
   Apple Silicon detected
   Selected backend: mps
==========================================
⚠️  Conda environment 'deepseek-ocr-mlx' not found
   Running with system Python

==================================================
🚀 DeepSeek-OCR Unified Service
==================================================
📍 URL: http://0.0.0.0:8001
📚 Docs: http://0.0.0.0:8001/docs
==================================================

INFO:     Started server process [15727]
INFO:     Waiting for application startup.
==================================================
🚀 DeepSeek-OCR Unified Service Starting...
==================================================
🔧 Forced backend: MPS
📦 Loading DeepSeek-OCR with MPS
processor_config.json: 100%|█████████████████████████████████████████████████████████████████| 460/460 [00:00<00:00, 317kB/s]
tokenizer_config.json: 166kB [00:00, 178MB/s]
tokenizer.json: 9.98MB [00:03, 3.27MB/s]
special_tokens_map.json: 100%|██████████████████████████████████████████████████████████████| 801/801 [00:00<00:00, 3.80MB/s]
config.json: 2.67kB [00:00, 7.47MB/s]
modeling_deepseekocr.py: 42.0kB [00:00, 397kB/s]
conversation.py: 9.25kB [00:00, 9.18MB/s]
deepencoder.py: 38.0kB [00:00, 27.4MB/s]
configuration_deepseek_v2.py: 10.6kB [00:00, 22.3MB/s]
modeling_deepseekv2.py: 82.2kB [00:00, 60.1MB/s]
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.
❌ Model loading failed: Using `low_cpu_mem_usage=True` or a `device_map` requires Accelerate: `pip install 'accelerate>=0.26.0'`
ERROR:    Traceback (most recent call last):
  File "/Users/niccoreyes/miniconda3/envs/deepseek-ocr/lib/python3.11/site-packages/starlette/routing.py", line 677, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/Users/niccoreyes/miniconda3/envs/deepseek-ocr/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/niccoreyes/Github/DeepSeek-OCR-WebUI/web_service_unified.py", line 211, in lifespan
    backend.load_model()
  File "/Users/niccoreyes/Github/DeepSeek-OCR-WebUI/backends/mps_backend.py", line 26, in load_model
    self.model = AutoModel.from_pretrained(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/niccoreyes/miniconda3/envs/deepseek-ocr/lib/python3.11/site-packages/transformers/models/auto/auto_factory.py", line 559, in from_pretrained
    return model_class.from_pretrained(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/niccoreyes/miniconda3/envs/deepseek-ocr/lib/python3.11/site-packages/transformers/modeling_utils.py", line 3577, in from_pretrained
    raise ImportError(
ImportError: Using `low_cpu_mem_usage=True` or a `device_map` requires Accelerate: `pip install 'accelerate>=0.26.0'`

ERROR:    Application startup failed. Exiting.

Which then I had to install

~/Github/DeepSeek-OCR-WebUI main ❯ pip install "accelerate>=0.26.0"                                       39s  deepseek-ocr

now I am currently at:

~/Github/DeepSeek-OCR-WebUI main ❯ ./start.sh                                                          3m 58s  deepseek-ocr
==========================================
🚀 DeepSeek-OCR-WebUI Startup
==========================================
🍎 Running on macOS
   Apple Silicon detected
   Selected backend: mps
==========================================
⚠️  Conda environment 'deepseek-ocr-mlx' not found
   Running with system Python

==================================================
🚀 DeepSeek-OCR Unified Service
==================================================
📍 URL: http://0.0.0.0:8001
📚 Docs: http://0.0.0.0:8001/docs
==================================================

INFO:     Started server process [17312]
INFO:     Waiting for application startup.
==================================================
🚀 DeepSeek-OCR Unified Service Starting...
==================================================
🔧 Forced backend: MPS
📦 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.
Downloading shards:   0%|                                                                              | 0/1 [00:00<?, ?it/s]
model-00001-of-000001.safetensors:  97%|██████████████████████████████████████████████▎ | 6.44G/6.67G [23:17<00:10, 22.5MB/s]

Download was successful but I encountered no webui error on http://localhost:8001

I had to build the UI first with:

cd frontend/
npm i
npm build
cd ..

before ./start.sh

Overall, it was successful after

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