Skip to content

Commit a9469c1

Browse files
committed
set PARALLEL_DEVICES default value= 0
1 parent 81b306a commit a9469c1

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

deepdoc/parser/pdf_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(self, **kwargs):
6161

6262
self.ocr = OCR()
6363
self.parallel_limiter = None
64-
if PARALLEL_DEVICES is not None and PARALLEL_DEVICES > 1:
64+
if PARALLEL_DEVICES > 1:
6565
self.parallel_limiter = [trio.CapacityLimiter(1) for _ in range(PARALLEL_DEVICES)]
6666

6767
if hasattr(self, "model_speciess"):

deepdoc/vision/ocr.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -529,31 +529,30 @@ def __init__(self, model_dir=None):
529529
"rag/res/deepdoc")
530530

531531
# Append muti-gpus task to the list
532-
if PARALLEL_DEVICES is not None and PARALLEL_DEVICES > 0:
532+
if PARALLEL_DEVICES > 0:
533533
self.text_detector = []
534534
self.text_recognizer = []
535535
for device_id in range(PARALLEL_DEVICES):
536536
self.text_detector.append(TextDetector(model_dir, device_id))
537537
self.text_recognizer.append(TextRecognizer(model_dir, device_id))
538538
else:
539-
self.text_detector = [TextDetector(model_dir, 0)]
540-
self.text_recognizer = [TextRecognizer(model_dir, 0)]
539+
self.text_detector = [TextDetector(model_dir)]
540+
self.text_recognizer = [TextRecognizer(model_dir)]
541541

542542
except Exception:
543543
model_dir = snapshot_download(repo_id="InfiniFlow/deepdoc",
544544
local_dir=os.path.join(get_project_base_directory(), "rag/res/deepdoc"),
545545
local_dir_use_symlinks=False)
546546

547-
if PARALLEL_DEVICES is not None:
548-
assert PARALLEL_DEVICES > 0, "Number of devices must be >= 1"
547+
if PARALLEL_DEVICES > 0:
549548
self.text_detector = []
550549
self.text_recognizer = []
551550
for device_id in range(PARALLEL_DEVICES):
552551
self.text_detector.append(TextDetector(model_dir, device_id))
553552
self.text_recognizer.append(TextRecognizer(model_dir, device_id))
554553
else:
555-
self.text_detector = [TextDetector(model_dir, 0)]
556-
self.text_recognizer = [TextRecognizer(model_dir, 0)]
554+
self.text_detector = [TextDetector(model_dir)]
555+
self.text_recognizer = [TextRecognizer(model_dir)]
557556

558557
self.drop_score = 0.5
559558
self.crop_image_res_index = 0

rag/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
PAGERANK_FLD = "pagerank_fea"
6363
TAG_FLD = "tag_feas"
6464

65-
PARALLEL_DEVICES = None
65+
PARALLEL_DEVICES = 0
6666
try:
6767
import torch.cuda
6868
PARALLEL_DEVICES = torch.cuda.device_count()

0 commit comments

Comments
 (0)