chongcb chongchuanbing Kevin Hu commited on
Commit
0de98c4
·
1 Parent(s): 40df4d9

fix: torch dependency start error (#2777)

Browse files

### 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 <[email protected]>
Co-authored-by: Kevin Hu <[email protected]>

Files changed (1) hide show
  1. deepdoc/parser/pdf_parser.py +6 -3
deepdoc/parser/pdf_parser.py CHANGED
@@ -45,9 +45,12 @@ class RAGFlowPdfParser:
45
 
46
  self.updown_cnt_mdl = xgb.Booster()
47
  if not LIGHTEN:
48
- import torch
49
- if torch.cuda.is_available():
50
- self.updown_cnt_mdl.set_param({"device": "cuda"})
 
 
 
51
  try:
52
  model_dir = os.path.join(
53
  get_project_base_directory(),
 
45
 
46
  self.updown_cnt_mdl = xgb.Booster()
47
  if not LIGHTEN:
48
+ try:
49
+ import torch
50
+ if torch.cuda.is_available():
51
+ self.updown_cnt_mdl.set_param({"device": "cuda"})
52
+ except Exception as e:
53
+ logging.error(str(e))
54
  try:
55
  model_dir = os.path.join(
56
  get_project_base_directory(),