VikParuchuri / marker

Convert PDF to markdown quickly with high accuracy
https://www.datalab.to
GNU General Public License v3.0
17.54k stars 1.01k forks source link

gpu setting #323

Open samqin123 opened 1 week ago

samqin123 commented 1 week ago

I've revised the setting.py as below, but when running marker or marker_single, still it works under CPU mode. ----reivsion --- line10: class Settings(BaseSettings):

General

TORCH_DEVICE: Optional[str] = "cuda"
.....

---end-----

running status log:

(surya) E:\marker>marker E:\pdf E:\pdf Loaded detection model vikp/surya_det3 on device cpu with dtype torch.float32 Loaded detection model vikp/surya_layout3 on device cpu with dtype torch.float32 Loaded reading order model vikp/surya_order on device cpu with dtype torch.float32 Loaded recognition model vikp/surya_rec2 on device cpu with dtype torch.float32 Config of the encoder: <class 'texify.model.model.VariableDonutSwinModel'> is overwritten by shared encoder config: VariableDonutSwinConfig { "attention_probs_dropout_prob": 0.0, "depths": [ 2, 2, 14, 2 ], "drop_path_rate": 0.1, "embed_dim": 128, "hidden_act": "gelu", "hidden_dropout_prob": 0.0, "hidden_size": 1024, "image_size": [ 420, 420 ], "initializer_range": 0.02, "layer_norm_eps": 1e-05, "mlp_ratio": 4.0, "model_type": "donut-swin", "num_channels": 3, "num_heads": [ 4, 8, 16, 32 ], "num_layers": 4, "patch_size": 4, "path_norm": true, "qkv_bias": true, "transformers_version": "4.46.0", "use_2d_embeddings": false, "use_absolute_embeddings": false, "window_size": 5 }

Config of the decoder: <class 'transformers.models.mbart.modeling_mbart.MBartForCausalLM'> is overwritten by shared decoder config: MBartConfig { "activation_dropout": 0.0, "activation_function": "gelu", "add_cross_attention": true, "add_final_layer_norm": true, "attention_dropout": 0.0, "bos_token_id": 0, "classifier_dropout": 0.0, "d_model": 1024, "decoder_attention_heads": 16, "decoder_ffn_dim": 4096, "decoder_layerdrop": 0.0, "decoder_layers": 8, "dropout": 0.1, "encoder_attention_heads": 16, "encoder_ffn_dim": 4096, "encoder_layerdrop": 0.0, "encoder_layers": 12, "eos_token_id": 2, "forced_eos_token_id": 2, "init_std": 0.02, "is_decoder": true, "is_encoder_decoder": false, "max_position_embeddings": 1536, "model_type": "mbart", "num_hidden_layers": 12, "pad_token_id": 1, "scale_embedding": true, "tie_word_embeddings": false, "transformers_version": "4.46.0", "use_cache": true, "vocab_size": 50000 }

Loaded texify model to cpu with torch.float32 dtype Loaded recognition model vikp/surya_tablerec on device cpu with dtype torch.float32 Converting 1 pdfs in chunk 1/1 with 1 processes, and storing in E:\pdf Detecting bboxes: 100%|██████████████████████████████████████████████████████████████████| 1/1 [00:07<00:00, 7.52s/it] Detecting bboxes: 100%|██████████████████████████████████████████████████████████████████| 1/1 [00:06<00:00, 6.92s/it] Finding reading order: 100%|█████████████████████████████████████████████████████████████| 1/1 [00:09<00:00, 9.96s/it] Recognizing tables: 100%|████████████████████████████████████████████████████████████████| 1/1 [00:01<00:00, 1.12s/it] Recognizing equations: 100%|█████████████████████████████████████████████████████████████| 1/1 [00:03<00:00, 3.43s/it] Processing PDFs: 100%|██████████████████████████████████████████████████████████████████| 1/1 [00:30<00:00, 30.32s/pdf]

samqin123 commented 1 week ago

pip show torch is fine (surya) E:\marker>pip show torch Name: torch Version: 2.5.0 Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration Home-page: https://pytorch.org/ Author: PyTorch Team Author-email: packages@pytorch.org License: BSD-3-Clause Location: c:\programdata\miniconda3\envs\surya\lib\site-packages Requires: filelock, fsspec, jinja2, networkx, sympy, typing-extensions Required-by: marker-pdf, surya-ocr, texify