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

关于使用相机流抽帧中显存的问题 #126

Open
yuzhj opened this issue Jul 26, 2024 · 7 comments
Open

关于使用相机流抽帧中显存的问题 #126

yuzhj opened this issue Jul 26, 2024 · 7 comments
Labels
good first issue Good for newcomers

Comments

@yuzhj
Copy link

yuzhj commented Jul 26, 2024

当使用样例脚本对相机流进行抽帧的时候,发现1080p的流,会占用300M+的显存,请问这个分配的大小是可以手动设置的吗,或者是可以在哪里进行修改,因为单纯只进行抽帧的话,并不需要这么多的显存空间。

@JackLau1222
Copy link
Collaborator

由于demo/video_frame_extraction中 jpeg_encoder这个module是基于gpu处理的
如果不想使用gpu处理的话,encoder的实现需要改 或者可以尝试使用bmf原生的
decoder也可以设置为cpu处理 在video_params中删掉下面两行参数

"hwaccel": "cuda",
"hwaccel_output_format": "cuda",

@yuzhj
Copy link
Author

yuzhj commented Jul 26, 2024

由于demo/video_frame_extraction中 jpeg_encoder这个module是基于gpu处理的 如果不想使用gpu处理的话,encoder的实现需要改 或者可以尝试使用bmf原生的 decoder也可以设置为cpu处理 在video_params中删掉下面两行参数

"hwaccel": "cuda",
"hwaccel_output_format": "cuda",

是要用gpu的,是decode那一块占用的显存太多了,因为考虑到1080p的一张图片也就几M的显存,但是使用bmf拉一个1080p的相机流,会占用300多M的显存,所以想问有没有办法通过代码或者设置降低这一块的显存。

@sfeiwong
Copy link
Collaborator

sfeiwong commented Jul 26, 2024

试一下控制threads:

    video = graph.decode({
        "input_path": "input.mp4",
        "video_params": {
            "hwaccel": "cuda",
            "hwaccel_output_format": "cuda",
        },
        "dec_params": {
            "threads": "2"
        }
    })["video"]

@yuzhj
Copy link
Author

yuzhj commented Jul 26, 2024

试一下控制threads:

    video = graph.decode({
        "input_path": "input.mp4",
        "video_params": {
            "hwaccel": "cuda",
            "hwaccel_output_format": "cuda",
        },
        "dec_params": {
            "threads": "2"
        }
    })["video"]

降低threads有效,设置了之后,占用的显存降低了,关于这些参数的具体含义有更详细的文档解释吗,因为目前看文档只有比较粗的介绍。

@sfeiwong sfeiwong added the good first issue Good for newcomers label Jul 26, 2024
@sfeiwong
Copy link
Collaborator

这个decode可以参考:https://babitmf.github.io/docs/bmf/api/decode_module/
更详细的介绍和背景原理之类的,可能需要查阅一些有关cuda、ffmpeg的文档来交叉印证。

@yuzhj
Copy link
Author

yuzhj commented Jul 29, 2024

这个decode可以参考:https://babitmf.github.io/docs/bmf/api/decode_module/ 更详细的介绍和背景原理之类的,可能需要查阅一些有关cuda、ffmpeg的文档来交叉印证。

通过降低线程数,可以降低显存,我理解应该有一个初始化显存池子的地方,在decode的过程中,初始化显存的地方可以告诉一下在哪里吗?

@JackLau1222
Copy link
Collaborator

这个decode可以参考:https://babitmf.github.io/docs/bmf/api/decode_module/ 更详细的介绍和背景原理之类的,可能需要查阅一些有关cuda、ffmpeg的文档来交叉印证。

通过降低线程数,可以降低显存,我理解应该有一个初始化显存池子的地方,在decode的过程中,初始化显存的地方可以告诉一下在哪里吗?

https://github.com/BabitMF/bmf/blob/master/bmf/hml/src/cuda/cuda_allocator.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants