Files
OCR/backend
egg b997f9355a fix: make torch import optional and add PaddlePaddle GPU memory management
Problem:
- Backend failed to start with ModuleNotFoundError for torch module
- torch was imported as hard dependency but not in requirements.txt
- Project uses PaddlePaddle which has its own CUDA implementation

Changes:
- Make torch import optional with try/except in ocr_service.py
- Make torch import optional in pp_structure_enhanced.py
- Add cleanup_gpu_memory() method using PaddlePaddle's memory management
- Add check_gpu_memory() method to monitor available GPU memory
- Use paddle.device.cuda.empty_cache() for GPU cleanup
- Use torch.cuda only if TORCH_AVAILABLE flag is True
- Add cleanup calls after OCR processing to prevent OOM errors
- Add memory checks before GPU-intensive operations

Benefits:
- Backend can start without torch installed
- GPU memory is properly managed using PaddlePaddle
- Optional torch support provides additional memory monitoring
- Prevents GPU OOM errors during document processing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 16:40:44 +08:00
..
2025-11-12 22:53:17 +08:00
2025-11-12 22:53:17 +08:00
2025-11-12 22:53:17 +08:00
2025-11-12 22:53:17 +08:00