Agent: support CPU-only mode in parallel_extract.py#715
Merged
Conversation
- Allow --gpus "" to force CPU-only mode - Rename --num-workers to --cpu-workers for clarity - Fix worker count logging to show CPU/GPU worker type - Update --gpus help text
|
Thanks for your contribution! |
- When --cpu-workers is set, force CPU-only mode regardless of GPU availability - Default CPU workers to half of CPU cores to avoid overloading the system - Rename --num-workers to --cpu-workers for clarity - Fix worker count logging to show correct CPU/GPU worker type
Xreki
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Category
Feature Enhancement
Description
问题
在没有这些修改的情况下,
parallel_extract.py可以跑 CPU,但受限制:torch.cuda.is_available()返回 False 时(即机器没有 GPU 或 CUDA 未安装),才会自动进入 CPU 模式--gpus ""参数切换到纯 CPU 模式。因为get_gpu_ids()对空字符串的处理是 fallback 到_get_default_gpus(),返回[0]CUDA_VISIBLE_DEVICES=""来隐藏 GPU,让 torch 检测不到 CUDA,从而进入 CPU 模式因此,如果需要在有 GPU 的机器上主动选择 CPU-only 模式,就必须做这些修改。
修改内容
--cpu-workers触发 CPU-only 模式:当--cpu-workers被设置时(且值 > 0),强制进入 CPU-only 模式,--gpus参数不再生效torch.cuda.is_available()返回 False 时自动进入 CPU-only 模式--cpu-workers自定义--num-workers→--cpu-workers:参数语义更明确,专用于 CPU-only 模式下的 worker 数量使用方式