Skip to content

feat: control CUDA deps#11355

Closed
moonstruxx wants to merge 3 commits intoinfiniflow:mainfrom
moonstruxx:v22
Closed

feat: control CUDA deps#11355
moonstruxx wants to merge 3 commits intoinfiniflow:mainfrom
moonstruxx:v22

Conversation

@moonstruxx
Copy link
Copy Markdown

@moonstruxx moonstruxx commented Nov 19, 2025

What problem does this PR solve?

  • Pre-install CPU-only PyTorch to avoid GPU version (saves ~4-5GB)
  • Add BUILD_MINERU build arg for optional mineru installation
  • Modify pip_install_torch() to default to CPU-only PyTorch
  • Update entrypoint to handle CPU-only PyTorch for mineru
  • Add comprehensive documentation for CUDA optimizations

Benefits:

  • Reduces image size from ~6-8GB to ~2-3GB (60-70% reduction)
  • Eliminates massive CUDA package downloads during build/runtime
  • Maintains full functionality with CPU processing
  • Optional GPU support via GPU_PYTORCH=true environment variable
  • Significantly faster build times and reduced bandwidth usage

Fixes: Docker image downloading tons of CUDA packages unnecessarily

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

- Pre-install CPU-only PyTorch to avoid GPU version (saves ~4-5GB)
- Add BUILD_MINERU build arg for optional mineru installation
- Modify pip_install_torch() to default to CPU-only PyTorch
- Update entrypoint to handle CPU-only PyTorch for mineru
- Add comprehensive documentation for CUDA optimizations

Benefits:
- Reduces image size from ~6-8GB to ~2-3GB (60-70% reduction)
- Eliminates massive CUDA package downloads during build/runtime
- Maintains full functionality with CPU processing
- Optional GPU support via GPU_PYTORCH=true environment variable
- Significantly faster build times and reduced bandwidth usage

Fixes: Docker image downloading tons of CUDA packages unnecessarily
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. 📖 documentation Improvements or additions to documentation labels Nov 19, 2025
- Fix uv pip install syntax to use --python flag instead of incorrect venv activation
- Add proper CPU-only PyTorch installation in main and mineru environments
- Update entrypoint scripts to check for pre-installed packages first
- Ensure proper fallback to runtime installation when needed

The previous commit only included documentation files, this commit adds the actual implementation.
Signed-off-by: Björn thorwirth <moonstruxx@googlemail.com>
@moonstruxx
Copy link
Copy Markdown
Author

srry .. firs request was accident .. now it's tested

Comment thread docker/entrypoint.sh
return 1
else
echo "[mineru] installed: ${MINERU_EXECUTABLE}"
return 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @moonstruxx

Thank you for your contribution. This looks good to me.

But I think here it should return 0 to indicate that MinerU has been installed successfully. Returning a non-zero value will cause the program to fail unexpectedly. However, since we have the restart: on-failure strategy, it will succeed on the next try.

I personally recommend changing it to express the correct semantic meaning. However, as I said, it doesn't really matter. It's up to you.

Cheers.

@KevinHuSh KevinHuSh added the ci Continue Integration label Nov 20, 2025
@KevinHuSh KevinHuSh marked this pull request as draft November 20, 2025 01:56
@KevinHuSh KevinHuSh marked this pull request as ready for review November 20, 2025 01:56
@dosubot dosubot Bot added the 🐞 bug Something isn't working, pull request that fix bug. label Nov 20, 2025
@KevinHuSh
Copy link
Copy Markdown
Collaborator

CI failure.
image

@yuzhichang
Copy link
Copy Markdown
Member

@yongtenglei It's better to add a group to pyproject.toml and install them at building phase than installing at container startup phase.

1 similar comment
@yuzhichang
Copy link
Copy Markdown
Member

@yongtenglei It's better to add a group to pyproject.toml and install them at building phase than installing at container startup phase.

@KevinHuSh
Copy link
Copy Markdown
Collaborator

Appreciations!
By our evaluations, this feature is not going to be merged into main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration 📖 documentation Improvements or additions to documentation size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants