idiap / fast-transformers

Pytorch library for fast transformer implementations
1.65k stars 179 forks source link

No module named 'fast_transformers.causal_product.causal_product_cpu' #63

Closed lonce closed 3 years ago

lonce commented 3 years ago

Hi, I am not sure how the compiled packages are supposed to work, but I am getting a 'no module' error just trying to run the 'Quick Start' code:

The installation went just fine with pip install --user pytorch-fast-transformers as can be seen: `$ pip install --user pytorch-fast-transformers

Requirement already satisfied: pytorch-fast-transformers in /home/lonce/.local/lib/python3.7/site-packages (0.3.0)
Requirement already satisfied: torch in /home/lonce/miniconda3/envs/pytorch/lib/python3.7/site-packages (from pytorch-fast-transformers) (1.7.1)
Requirement already satisfied: typing_extensions in /home/lonce/miniconda3/envs/pytorch/lib/python3.7/site-packages (from torch->pytorch-fast-transformers) (3.7.4.3)
Requirement already satisfied: numpy in /home/lonce/miniconda3/envs/pytorch/lib/python3.7/site-packages (from torch->pytorch-fast-transformers) (1.19.2)`

This is what my causal_product directory looks like: `$ ls fast_transformers/causal_product/

causal_product_cpu.cpp causal_product_cuda.cu init.py pycache`

But when I try to import TransformerEncoderBuilder, the module can't be found: `$ python Python 3.7.9 | packaged by conda-forge | (default, Dec 9 2020, 21:08:20)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import torch
from fast_transformers.builders import TransformerEncoderBuilder

Traceback (most recent call last):
File "", line 1, in
File "/home/lonce/working/fast-transformers/fast_transformers/builders/init.py", line 42, in from ..attention import \
File "/home/lonce/working/fast-transformers/fast_transformers/attention/init.py", line 13, in from .causal_linear_attention import CausalLinearAttention
File "/home/lonce/working/fast-transformers/fast_transformers/attention/causal_linear_attention.py", line 15, in
from ..causal_product import causal_dot_product
File "/home/lonce/working/fast-transformers/fast_transformers/causal_product/init.py", line 9, in from .causal_product_cpu import causal_dot_product as causal_dot_product_cpu, \
ModuleNotFoundError: No module named 'fast_transformers.causal_product.causal_product_cpu'

`

Of course, any guidance would be greatly appreciated.
lonce

lonce commented 3 years ago

Ackk! This is a non-issue. Close please, my bad. Works much better when you start from the right directory.

nicolasugrinovic commented 3 years ago

Hi @lonce I have the same problem. What do you mean with right directory? Which directory are you running the code from?

lonce commented 3 years ago

You are probably in the directory where you did your setup, so change to the fast_transformers directory to run your code.

nicolasugrinovic commented 3 years ago

Thanks! Just for the record, I tried that and didn't work as in my case the problem was that some cpp extensions where not compiled, what solved my issue was to build the library directly from the github repo:

python setup.py build_ext --inplace

Like it is mentioned here https://github.com/idiap/fast-transformers/issues/12#issuecomment-660869837

Acciorocketships commented 12 months ago

Can anyone explain how to get this working? I am having the same issue and nothing seems to work. I have tried running from different directories, running python setup.py build_ext --inplace, installing with --no-binary, and installing with --no-cache-dir.