Skip to content
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

Open
randydl opened this issue Sep 24, 2024 · 10 comments
Open

"device-mode": "cuda:1",请问可不可以这样写? #655

randydl opened this issue Sep 24, 2024 · 10 comments
Labels
enhancement New feature or request

Comments

@randydl
Copy link

randydl commented Sep 24, 2024

{
    "bucket_info":{
        "bucket-name-1":["ak", "sk", "endpoint"],
        "bucket-name-2":["ak", "sk", "endpoint"]
    },
    "models-dir":"/tmp/models",
    "device-mode":"cuda:1",
    "table-config": {
        "model": "TableMaster",
        "is_table_recog_enable": false,
        "max_time": 400
    }
}
@randydl randydl added the enhancement New feature or request label Sep 24, 2024
@myhloli
Copy link
Collaborator

myhloli commented Sep 24, 2024

可以

@xiangru2020
Copy link

可以

晓萌你好,按照步骤安装后测试时输入magic-pdf -p small_ocr.pdf报错

Usage: magic-pdf [OPTIONS]
Try 'magic-pdf --help' for help.
Error: Missing option '-o' / '--output-dir'.

这个测试的时候也需要指定输出路径吗?

@myhloli
Copy link
Collaborator

myhloli commented Sep 24, 2024

可以

晓萌你好,按照步骤安装后测试时输入magic-pdf -p small_ocr.pdf报错

Usage: magic-pdf [OPTIONS]

Try 'magic-pdf --help' for help.

Error: Missing option '-o' / '--output-dir'.

这个测试的时候也需要指定输出路径吗?

需要指定输出路径

@xiangru2020
Copy link

可以

晓萌你好,按照步骤安装后测试时输入magic-pdf -p small_ocr.pdf报错
Usage: magic-pdf [OPTIONS]
Try 'magic-pdf --help' for help.
Error: Missing option '-o' / '--output-dir'.
这个测试的时候也需要指定输出路径吗?

需要指定输出路径

好的,谢谢~

@xiangru2020
Copy link

可以

另外,需要下载项目包吗?给的例子里面没有要求下载release的压缩包,我看了很多其他教程都需要下载,并且在项目包里打开环境运行,不过我没有下载也跑通了

@myhloli
Copy link
Collaborator

myhloli commented Sep 24, 2024

可以

另外,需要下载项目包吗?给的例子里面没有要求下载release的压缩包,我看了很多其他教程都需要下载,并且在项目包里打开环境运行,不过我没有下载也跑通了

不需要下载

@xiangru2020
Copy link

可以

另外,需要下载项目包吗?给的例子里面没有要求下载release的压缩包,我看了很多其他教程都需要下载,并且在项目包里打开环境运行,不过我没有下载也跑通了

不需要下载

好的,谢谢晓萌~

@randydl
Copy link
Author

randydl commented Sep 24, 2024

谢谢晓萌,我现在想通过api的方式调用,用多进程的方式在多个GPU上加载咱们的模型(每个gpu一个),我希望在每个进程中传递device编号来初始化模型,但是我发现咱们的初始化方法只能读取~/magic-pdf.json,里面的device-mode是写死的,无法更改,ModelSingleton里面也没有参数可以传递device,请问这个有没有好的方式解决?

@randydl
Copy link
Author

randydl commented Sep 25, 2024

我这边解决了,用了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)

@xiangru2020
Copy link

可以

嘻嘻,我又来借楼了~,呼叫晓萌,请问脚本里面model_json_path所说的内置模型是啥,是单独下载的(在magic-pdf.json里面指定路径的)那个吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants