-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"device-mode": "cuda:1",请问可不可以这样写? #655
Comments
可以 |
晓萌你好,按照步骤安装后测试时输入magic-pdf -p small_ocr.pdf报错 Usage: magic-pdf [OPTIONS] 这个测试的时候也需要指定输出路径吗? |
需要指定输出路径 |
好的,谢谢~ |
另外,需要下载项目包吗?给的例子里面没有要求下载release的压缩包,我看了很多其他教程都需要下载,并且在项目包里打开环境运行,不过我没有下载也跑通了 |
不需要下载 |
好的,谢谢晓萌~ |
谢谢晓萌,我现在想通过api的方式调用,用多进程的方式在多个GPU上加载咱们的模型(每个gpu一个),我希望在每个进程中传递device编号来初始化模型,但是我发现咱们的初始化方法只能读取~/magic-pdf.json,里面的device-mode是写死的,无法更改,ModelSingleton里面也没有参数可以传递device,请问这个有没有好的方式解决? |
我这边解决了,用了mock的方法来修改get_device函数的返回值: def init_model():
from magic_pdf.model.doc_analyze_by_custom_model import ModelSingleton
try:
model_manager = ModelSingleton()
txt_model = model_manager.get_model(False, False)
logger.info(f"txt_model init final")
ocr_model = model_manager.get_model(True, False)
logger.info(f"ocr_model init final")
return 0
except Exception as e:
logger.exception(e)
return -1
if __name__ == "__main__":
import time
from unittest.mock import patch
with patch('magic_pdf.model.doc_analyze_by_custom_model.get_device') as mock_get_device:
mock_get_device.return_value = 'cuda:1'
model_init = init_model()
logger.info(f"model_init: {model_init}")
time.sleep(3600) |
嘻嘻,我又来借楼了~,呼叫晓萌,请问脚本里面model_json_path所说的内置模型是啥,是单独下载的(在magic-pdf.json里面指定路径的)那个吗? |
The text was updated successfully, but these errors were encountered: