Fix flash-attn install failing with 'No module named torch'#135
Open
gt12889 wants to merge 1 commit into
Open
Conversation
…an-longcat#126) pip builds flash-attn in an isolated env where torch is not installed, so the build fails even though torch is right there in your env. Add --no-build-isolation to the README install step, and drop torch + flash-attn from requirements.txt since they are already handled by their own install steps.
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.
What
Fixes the
flash_attninstall failure reported in #126(
ModuleNotFoundError: No module named 'torch').Why
flash-attn'ssetup.pyimportstorchat build time. pip builds it in anisolated environment by default, where torch isn't present, so the build fails
even when torch is already installed in the target env.
The failure happens twice with the current setup:
pip install flash_attn==2.7.4.post1step.pip install -r requirements.txt, which also listsflash-attn.Changes
--no-build-isolationso it links against thetorch installed in the previous step.
requirements.txt: removeflash-attn(installed via its own documented step)and
torch(installed from the cu124 index, so the plaintorch==2.6.0herecan pull a CPU build over it).
Fixes #126