opendatalab / PDF-Extract-Kit

A Comprehensive Toolkit for High-Quality PDF Content Extraction
https://pdf-extract-kit.readthedocs.io/zh-cn/latest/index.html
GNU Affero General Public License v3.0
5.15k stars 346 forks source link

求助,from detectron2 import _C,报错! #5

Closed xeon-ye closed 3 months ago

xeon-ye commented 3 months ago

File "C:\Users\XXX\miniconda3\lib\site-packages\detectron2\layers\deform_conv.py", line 11, in from detectron2 import _C ImportError: DLL load failed while importing _C: 找不到指定的模块。

wufan-tb commented 3 months ago

看起来像detectron2没有安装成功或者版本对应不上,是否按照这个流程安装的呢, image 如果按照流程也不行可以尝试下载detectron2的源码去编译安装

xeon-ye commented 3 months ago

谢谢,尝试下源码安装

xeon-ye commented 3 months ago

源码安装成功,又有了新情况,pytorch gpu环境的问题?(pipeline) PS C:\PDF-Extract-Kit> python pdf_extract.py --pdf .\assets\examples\example.pdf Namespace(pdf='.\assets\examples\example.pdf', output='output', vis=False, render=False) 2024-07-01 16:07:47 Started! CustomVisionEncoderDecoderModel init CustomMBartForCausalLM init CustomMBartDecoder init Traceback (most recent call last): File "C:\PDF-Extract-Kit\pdf_extract.py", line 93, in mfr_model, mfr_vis_processors = mfr_model_init(model_configs['model_args']['mfr_weight'], device=device) File "C:\PDF-Extract-Kit\pdf_extract.py", line 42, in mfr_model_init model = model.to(device) File "C:\Users\davyy\miniconda3\envs\pipeline\lib\site-packages\torch\nn\modules\module.py", line 1152, in to return self._apply(convert) File "C:\Users\davyy\miniconda3\envs\pipeline\lib\site-packages\torch\nn\modules\module.py", line 802, in _apply module._apply(fn) File "C:\Users\davyy\miniconda3\envs\pipeline\lib\site-packages\torch\nn\modules\module.py", line 802, in _apply module._apply(fn) File "C:\Users\miniconda3\envs\pipeline\lib\site-packages\torch\nn\modules\module.py", line 802, in _apply module._apply(fn) [Previous line repeated 3 more times] File "C:\Users\davyy\miniconda3\envs\pipeline\lib\site-packages\torch\nn\modules\module.py", line 825, in _apply param_applied = fn(param) File "C:\Users\davyy\miniconda3\envs\pipeline\lib\site-packages\torch\nn\modules\module.py", line 1150, in convert return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) File "C:\Users\davyy\miniconda3\envs\pipeline\lib\site-packages\torch\cuda__init__.py", line 293, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled (pipeline) PS C:\PDF-Extract-Kit> nvcc -V nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2023 NVIDIA Corporation Built on Fri_Jan__6_19:04:39_Pacific_Standard_Time_2023 Cuda compilation tools, release 12.0, V12.0.140 Build cuda_12.0.r12.0/compiler.32267302_0 (pipeline) PS C:\PDF-Extract-Kit> nvidia-smi.exe Mon Jul 1 16:11:16 2024 +---------------------------------------------------------------------------------------+ | NVIDIA-SMI 546.59 Driver Version: 546.59 CUDA Version: 12.3 | |-----------------------------------------+----------------------+----------------------+ | GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+======================+======================| | 0 NVIDIA GeForce RTX 3050 ... WDDM | 00000000:01:00.0 Off | N/A | | N/A 47C P3 12W / 35W | 0MiB / 4096MiB | 0% Default | | | | N/A | +-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=======================================================================================| | No running processes found | +---------------------------------------------------------------------------------------+

myhloli commented 3 months ago

在windows上使用有一些需要解决的依赖问题,我们今天已经测试并run起来了,稍晚会更新一篇如何在win平台通过cpu或gpu运行的文档。

xeon-ye commented 3 months ago

在win10已经跑起来了,速度太慢,最终磁盘空间消耗殆尽,未能正常导出。console 输出: (gpu) PS C:\PDF-Extract-Kit> python pdf_extract.py --pdf .\assets\examples\example.pdf Namespace(pdf='.\assets\examples\example.pdf', output='output', vis=False, render=False) 2024-07-02 07:29:23 Started! CustomVisionEncoderDecoderModel init CustomMBartForCausalLM init CustomMBartDecoder init [07/02 07:30:01 detectron2]: Rank of current process: 0. World size: 1 [07/02 07:30:03 detectron2]: Environment info:


sys.platform win32 Python 3.10.14 packaged by conda-forge (main, Mar 20 2024, 12:40:08) [MSC v.1938 64 bit (AMD64)] numpy 1.26.3 detectron2 0.6 @c:\detectron2\detectron2 Compiler MSVC 194033811 CUDA compiler not available DETECTRON2_ENV_MODULE PyTorch 2.3.1+cu121 @C:\Users\davyy\miniconda3\envs\gpu\lib\site-packages\torch PyTorch debug build False torch._C._GLIBCXX_USE_CXX11_ABI False GPU available Yes GPU 0 NVIDIA GeForce RTX 3050 Ti Laptop GPU (arch=8.6) Driver version 546.59 CUDA_HOME C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3 Pillow 8.4.0 torchvision 0.18.1+cu121 @C:\Users\davyy\miniconda3\envs\gpu\lib\site-packages\torchvision torchvision arch flags C:\Users\davyy\miniconda3\envs\gpu\lib\site-packages\torchvision_C.pyd; cannot find cuobjdump fvcore 0.1.5.post20221221 iopath 0.1.9 cv2 4.6.0

PyTorch built with:

[07/02 07:30:03 detectron2]: Command line arguments: {'config_file': 'modules/layoutlmv3/layoutlmv3_base_inference.yaml', 'resume': False, 'eval_only': False, 'num_gpus': 1, 'num_machines': 1, 'machine_rank': 0, 'dist_url': 'tcp://127.0.0.1:57823', 'opts': ['MODEL.WEIGHTS', 'models/Layout/model_final.pth']} [07/02 07:30:03 detectron2]: Contents of args.config_file=modules/layoutlmv3/layoutlmv3_base_inference.yaml: AUG: DETR: true CACHE_DIR: /mnt/localdata/users/yupanhuang/cache/huggingface CUDNN_BENCHMARK: false DATALOADER: ASPECT_RATIO_GROUPING: true FILTER_EMPTY_ANNOTATIONS: false NUM_WORKERS: 4 REPEAT_THRESHOLD: 0.0 SAMPLER_TRAIN: TrainingSampler DATASETS: PRECOMPUTED_PROPOSAL_TOPK_TEST: 1000 PRECOMPUTED_PROPOSAL_TOPK_TRAIN: 2000 PROPOSAL_FILES_TEST: [] PROPOSAL_FILES_TRAIN: [] TEST:

[07/02 07:30:08 d2.checkpoint.detection_checkpoint]: [DetectionCheckpointer] Loading from models/Layout/model_final.pth ... [07/02 07:30:08 fvcore.common.checkpoint]: [Checkpointer] Loading from models/Layout/model_final.pth ... [2024/07/02 07:30:09] ppocr DEBUG: Namespace(help='==SUPPRESS==', use_gpu=True, use_xpu=False, use_npu=False, ir_optim=True, use_tensorrt=False, min_subgraph_size=15, precision='fp32', gpu_mem=500, gpu_id=0, image_dir=None, page_num=0, det_algorithm='DB', det_model_dir='C:\Users\davyy/.paddleocr/whl\det\ch\ch_PP-OCRv4_det_infer', det_limit_side_len=960, det_limit_type='max', det_box_type='quad', det_db_thresh=0.3, det_db_box_thresh=0.6, det_db_unclip_ratio=1.5, max_batch_size=10, use_dilation=False, det_db_score_mode='fast', det_east_score_thresh=0.8, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_sast_score_thresh=0.5, det_sast_nms_thresh=0.2, det_pse_thresh=0, det_pse_box_thresh=0.85, det_pse_min_area=16, det_pse_scale=1, scales=[8, 16, 32], alpha=1.0, beta=1.0, fourier_degree=5, rec_algorithm='SVTR_LCNet', rec_model_dir='C:\Users\davyy/.paddleocr/whl\rec\ch\ch_PP-OCRv4_rec_infer', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_batch_num=6, max_text_length=25, rec_char_dict_path='C:\Users\davyy\miniconda3\envs\gpu\lib\site-packages\paddleocr\ppocr\utils\ppocr_keys_v1.txt', use_space_char=True, vis_font_path='./doc/fonts/simfang.ttf', drop_score=0.5, e2e_algorithm='PGNet', e2e_model_dir=None, e2e_limit_side_len=768, e2e_limit_type='max', e2e_pgnet_score_thresh=0.5, e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_pgnet_valid_set='totaltext', e2e_pgnet_mode='fast', use_angle_cls=False, cls_model_dir='C:\Users\davyy/.paddleocr/whl\cls\ch_ppocr_mobile_v2.0_cls_infer', cls_image_shape='3, 48, 192', label_list=['0', '180'], cls_batch_num=6, cls_thresh=0.9, enable_mkldnn=False, cpu_threads=10, use_pdserving=False, warmup=False, sr_model_dir=None, sr_image_shape='3, 32, 128', sr_batch_num=1, draw_img_save_dir='./inference_results', save_crop_res=False, crop_res_save_dir='./output', use_mp=False, total_process_num=1, process_id=0, benchmark=False, save_log_path='./log_output/', show_log=True, use_onnx=False, output='./output', table_max_len=488, table_algorithm='TableAttn', table_model_dir=None, merge_no_span_structure=True, table_char_dict_path=None, layout_model_dir=None, layout_dict_path=None, layout_score_threshold=0.5, layout_nms_threshold=0.5, kie_algorithm='LayoutXLM', ser_model_dir=None, re_model_dir=None, use_visual_backbone=True, ser_dict_path='../train_data/XFUND/class_list_xfun.txt', ocr_order_method=None, mode='structure', image_orientation=False, layout=True, table=True, ocr=True, recovery=False, use_pdf2docx_api=False, invert=False, binarize=False, alphacolor=(255, 255, 255), lang='ch', det=True, rec=True, type='ocr', ocr_version='PP-OCRv4', structure_version='PP-StructureV2') 2024-07-02 07:29:23 Model init done! total files: 1 pdf index: 0 pages: 5

0: 1888x1472 42 embeddings, 2 isolateds, 305.7ms Speed: 99.8ms preprocess, 305.7ms inference, 4.0ms postprocess per image at shape (1, 3, 1888, 1472)

myhloli commented 3 months ago

已更新windows使用指南,请参考https://github.com/opendatalab/PDF-Extract-Kit/blob/main/docs/Install_in_Windows_zh_cn.md

xeon-ye commented 3 months ago

😊