Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
MinerU
Commits
5f1a509f
Commit
5f1a509f
authored
Jun 12, 2025
by
myhloli
Browse files
feat: refactor device mode retrieval to use get_device utility
parent
a392f445
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
5 deletions
+4
-5
mineru/cli/client.py
mineru/cli/client.py
+4
-5
No files found.
mineru/cli/client.py
View file @
5f1a509f
...
@@ -4,6 +4,8 @@ import click
...
@@ -4,6 +4,8 @@ import click
from
pathlib
import
Path
from
pathlib
import
Path
import
torch
import
torch
from
loguru
import
logger
from
loguru
import
logger
from
mineru.utils.config_reader
import
get_device
from
mineru.utils.model_utils
import
get_vram
from
mineru.utils.model_utils
import
get_vram
from
..version
import
__version__
from
..version
import
__version__
from
.common
import
do_parse
,
read_fn
,
pdf_suffixes
,
image_suffixes
from
.common
import
do_parse
,
read_fn
,
pdf_suffixes
,
image_suffixes
...
@@ -144,11 +146,8 @@ def main(input_path, output_dir, method, backend, lang, server_url, start_page_i
...
@@ -144,11 +146,8 @@ def main(input_path, output_dir, method, backend, lang, server_url, start_page_i
def
get_device_mode
()
->
str
:
def
get_device_mode
()
->
str
:
if
device_mode
is
not
None
:
if
device_mode
is
not
None
:
return
device_mode
return
device_mode
if
torch
.
cuda
.
is_available
():
else
:
return
"cuda"
return
get_device
()
if
torch
.
backends
.
mps
.
is_available
():
return
"mps"
return
"cpu"
if
os
.
getenv
(
'MINERU_DEVICE_MODE'
,
None
)
is
None
:
if
os
.
getenv
(
'MINERU_DEVICE_MODE'
,
None
)
is
None
:
os
.
environ
[
'MINERU_DEVICE_MODE'
]
=
get_device_mode
()
os
.
environ
[
'MINERU_DEVICE_MODE'
]
=
get_device_mode
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment