apex icon indicating copy to clipboard operation
apex copied to clipboard

ModuleNotFoundError: No module named 'fast_multihead_attn'

Open ICENacl opened this issue 2 years ago • 4 comments

Describe the Bug after I install apex, "import apex.contrib.multihead_attn"produce this bug Minimal Steps/Code to Reproduce the Bug

  1. just install apex by using this command:pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --global-option="--cpp_ext" --global-option="--cuda_ext" ./
  2. "import apex.contrib.multihead_attn"

Expected Behavior

no bug occur

Environment

os:ubuntu python:3.10.6 cuda:11.6 pytorch:1.12.1

ICENacl avatar Aug 28 '23 06:08 ICENacl

my pip version is 22.1. it seems it is the pyproject.toml that influence pip install

when the pyproject.toml exists, the setup.py can not receive the arguments that we set, e.g --global-option="--cpp_ext" --global-option="--cuda_ext".

Because the missing arguments --fast_multihead_attn for setup.py, the extension multihead_attn is not built, producing bug when using import apex.contrib.multihead_attn

The relationship between pyproject.toml and setup.py can be found in Build System Interface

ICENacl avatar Aug 28 '23 07:08 ICENacl

wouldn't python setup.py install --fast_multihead_attn work?

crcrpar avatar Aug 28 '23 12:08 crcrpar

wouldn't python setup.py install --fast_multihead_attn work?

I have tried python setup.py install --fast_multihead_attn, it cause another build problem.

It seems like that pip install consider pyproject.toml firstly to build apex, and then try setup.py, so setup.py can not receive the arguments.

ICENacl avatar Aug 29 '23 07:08 ICENacl

git clone https://github.com/NVIDIA/apex.git

cd apex git branch -a git checkout -b 22.04-dev origin/22.04-dev

pip uninstall apex

pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" --global-option="--fast_multihead_attn" ./

biandh avatar Dec 14 '23 13:12 biandh