NVIDIA / apex

A PyTorch Extension: Tools for easy mixed precision and distributed training in Pytorch
BSD 3-Clause "New" or "Revised" License
8.42k stars 1.4k forks source link

ModuleNotFoundError: No module named 'fast_multihead_attn' #1717

Open ICENacl opened 1 year ago

ICENacl commented 1 year ago

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 commented 1 year ago

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

crcrpar commented 1 year ago

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

ICENacl commented 1 year ago

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.

biandh commented 11 months ago

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" ./