-
Notifications
You must be signed in to change notification settings - Fork 581
bugfix: fix cli error when cuda toolkit is not installed #1905
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
Conversation
Summary of ChangesHello @yzh119, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a specific issue where the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request aims to fix a crash in the CLI when the CUDA toolkit is not installed. The change correctly removes a direct call to get_cuda_path() which could raise an unhandled exception during module import. However, the fix is incomplete as there are other calls (get_cuda_version()) that can still cause the same crash. My review points out this remaining issue and suggests a more robust solution by handling all potentially failing calls in try-except blocks, similar to the pattern already applied for CUDA_HOME.
| "FLASHINFER_CUDA_ARCH_LIST": current_compilation_context.TARGET_CUDA_ARCHS, | ||
| "FLASHINFER_CUDA_VERSION": get_cuda_version(), | ||
| "FLASHINFER_CUBINS_REPOSITORY": FLASHINFER_CUBINS_REPOSITORY, | ||
| "CUDA_HOME": get_cuda_path(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this line is correct to prevent a crash when the CUDA toolkit is not installed. However, the calls to get_cuda_version() on lines 80 and 83 can still cause the same issue. They should also be handled gracefully, for example by moving them into a try-except block, similar to how CUDA_HOME is now handled. Additionally, get_cuda_version() is called twice; it would be more efficient to call it once and reuse the result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it seems like we want to print "CUDA_HOME" regardless of whether nvcc is there. Dropping it silently seems like it could cause confusion.
Maybe we need a refactor so we can separately print:
- CUDA_HOME
- Whether or not nvcc was found
- Whether or not the other CUDA dependencies were found (like cudart)
- CUDA_VERSION of whatever was found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently it looks like, if there's no nvcc, CUDA_HOME will show as "not found" even if the env var is set, which is confusing to me, because even if the user doesn't have nvcc, they still may want to point to a CUDA_HOME for other CUDA deps, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated according to suggestions:
- Use a standalone section displaying whether NVCC is found or not.
- When
CUDA_HOMEis not set, we will print "" for the environment variable. - For CUDA runtime, we use
torch.cuda.is_available()to determine whether it's available.
📌 Description
This is a bugfix to #1904.
🔍 Related Issues
#1904
🚀 Pull Request Checklist
Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.
✅ Pre-commit Checks
pre-commitby runningpip install pre-commit(or used your preferred method).pre-commit install.pre-commit run --all-filesand fixed any reported issues.🧪 Tests
unittest, etc.).Reviewer Notes
cc @bbartels