mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: force CPU mode in download_models.py for build-time compatibility
paddlepaddle-gpu tries to load libcuda.so.1 on import, but no GPU driver exists during Docker build. Set PADDLE_DEVICE=cpu, FLAGS_use_cuda=0, and CUDA_VISIBLE_DEVICES="" before any ML imports to force CPU mode.
This commit is contained in:
@@ -7,6 +7,12 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
||||||
|
# Force CPU mode during build - no GPU driver available at build time.
|
||||||
|
# Must be set before any ML library import.
|
||||||
|
os.environ["PADDLE_DEVICE"] = "cpu"
|
||||||
|
os.environ["FLAGS_use_cuda"] = "0"
|
||||||
|
os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
||||||
|
|
||||||
REALESRGAN_MODEL_DIR = "/opt/models/realesrgan"
|
REALESRGAN_MODEL_DIR = "/opt/models/realesrgan"
|
||||||
REALESRGAN_MODEL_URL = (
|
REALESRGAN_MODEL_URL = (
|
||||||
"https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth"
|
"https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth"
|
||||||
@@ -58,6 +64,9 @@ def download_paddleocr_models():
|
|||||||
"""Pre-download PaddleOCR models for all supported languages."""
|
"""Pre-download PaddleOCR models for all supported languages."""
|
||||||
print("=== Downloading PaddleOCR models ===")
|
print("=== Downloading PaddleOCR models ===")
|
||||||
os.environ["PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK"] = "True"
|
os.environ["PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK"] = "True"
|
||||||
|
# Force CPU mode during build - no GPU driver available at build time
|
||||||
|
os.environ["PADDLE_DEVICE"] = "cpu"
|
||||||
|
os.environ["FLAGS_use_cuda"] = "0"
|
||||||
from paddleocr import PaddleOCR
|
from paddleocr import PaddleOCR
|
||||||
|
|
||||||
for lang in PADDLEOCR_LANGUAGES:
|
for lang in PADDLEOCR_LANGUAGES:
|
||||||
|
|||||||
Reference in New Issue
Block a user