VikParuchuri / marker

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

convert.py crashes with CUDA error and hangs on CPU #95

Open thawn opened 4 months ago

thawn commented 4 months ago

I am trying to batch convert two small (test) pdfs with the following command:

python convert.py pdf/ markdown/

crashes with a runtime error

Traceback (most recent call last):
  File "/app/marker/convert.py", line 127, in <module>
    main()
  File "/app/marker/convert.py", line 116, in main
    finished_lst = ray.get(finished)
                   ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ray/_private/auto_init_hook.py", line 21, in auto_init_wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ray/_private/client_mode_hook.py", line 103, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ray/_private/worker.py", line 2667, in get
    values, debugger_breakpoint = worker.get_objects(object_refs, timeout=timeout)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ray/_private/worker.py", line 864, in get_objects
    raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(RaySystemError): ray::process_single_pdf() (pid=148601, ip=10.0.23.4)
  At least one of the input arguments for this task could not be computed:
ray.exceptions.RaySystemError: System error: CUDA error: CUDA-capable device(s) is/are busy or unavailable
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

If I run the same command on CPU, the process hangs indefinitely

TORCH_DEVICE=cpu python convert.py pdf/ markdown/

however, converting a single pdf works like a charm:

python convert_single.py pdf/file1.pdf markdown/file1.md