flash-attention icon indicating copy to clipboard operation
flash-attention copied to clipboard

ModuleNotFoundError: No module named 'torch'

Open lucasjinreal opened this issue 2 years ago • 11 comments

torch actually installed

lucasjinreal avatar May 31 '23 10:05 lucasjinreal

try pip install flash-attn --no-build-isolation. it works for me

xwyzsn avatar May 31 '23 14:05 xwyzsn

this cant be done within a setup.py file in my project...

vchiley avatar Jun 02 '23 22:06 vchiley

Maybe regressing to older version of flash-attn is sufficient. I succeed with flash-attn==1.0.4

REIGN12 avatar Jun 08 '23 02:06 REIGN12

I'm getting below with --no-build-isolation as well as with 1.0.4.

ModuleNotFoundError: No module named 'torch.utils'

sytelus avatar Jun 09 '23 08:06 sytelus

We recommend the Pytorch container from Nvidia, which has all the required tools to install FlashAttention.

tridao avatar Jun 09 '23 08:06 tridao

I'm getting below with --no-build-isolation as well as with 1.0.4.

ModuleNotFoundError: No module named 'torch.utils'

Looks like the issue was that my anaconda install was in /anaconda and therefore required sudo. After reinstalling anaconda in ~/, --no-build-isolation is working now.

Also, I installed Pytorch nighly build that works with CUDA 12.0.

It would be GREAT to retain ability to build things outside one specific container!

sytelus avatar Jun 09 '23 08:06 sytelus

Seeing ModuleNotFoundError: No module named 'torch' during an install is probably because the setup.py is technically incorrect.

python needs more details about dependencies during build time and it's not being threaded through the entire project definition (and it's not great/safe to be calling other installed libraries during install time, etc).

It looks like this is project borrowed a copy of the broken detectron2 setup script which they also haven't fixed for years so the infrastructure contagion is spreading 🫠

also see:

  • https://github.com/python-poetry/poetry/issues/2113
  • https://github.com/python-poetry/poetry/issues/2113#issuecomment-1145937065
  • https://github.com/python-poetry/poetry/issues/2113#issuecomment-1221601986

mattsta avatar Jun 23 '23 05:06 mattsta

I had to remove pyproject.toml for now since I couldn't find a way to add torch as a build dependencies that work for everyone. Hopefully installation would work for the newest version (1.0.8).

tridao avatar Jul 03 '23 00:07 tridao

Hi, the installation doesn't work for me with 1.0.8. Same error

 ModuleNotFoundError: No module named 'torch'

zerogerc avatar Jul 03 '23 09:07 zerogerc

--no-build-isolation works for me with 1.0.8, torch==2.0.0+cu117.

kylematoba avatar Jul 06 '23 05:07 kylematoba

This issue is a dupe of #246.

jaraco avatar Mar 26 '24 19:03 jaraco