fix: torch dependency start error (#2777)

### What problem does this PR solve?

when use slim image, remove ```torch``` denpendency.

### Type of change

- [✓] Bug Fix (non-breaking change which fixes an issue)

---------

Co-authored-by: chongchuanbing <chongchuanbing@gmail.com>
Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
chongchuanbing 2024-10-10 10:06:03 +08:00 committed by GitHub
parent 29f022c91c
commit 66172cef3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,9 +45,12 @@ class RAGFlowPdfParser:
self.updown_cnt_mdl = xgb.Booster()
if not LIGHTEN:
import torch
if torch.cuda.is_available():
self.updown_cnt_mdl.set_param({"device": "cuda"})
try:
import torch
if torch.cuda.is_available():
self.updown_cnt_mdl.set_param({"device": "cuda"})
except Exception as e:
logging.error(str(e))
try:
model_dir = os.path.join(
get_project_base_directory(),