ROCm / flash-attention

Fast and memory-efficient exact attention
BSD 3-Clause "New" or "Revised" License
131 stars 41 forks source link

installation error of Method 1 with the recommended docker #25

Closed donglixp closed 10 months ago

donglixp commented 10 months ago

I used Method I and the recommended docker to install the package (https://github.com/ROCmSoftwarePlatform/flash-attention?tab=readme-ov-file#method-1-build-from-source ). The error message is as follows:

tention/csrc/flash_attn_rocm/src/flash_bwd_runner_batched_hdim64_bf16_noncausal_gfx9x_hip.hip [ok]
      /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_bwd_runner_grouped_hdim64_fp16_causal_gfx9x.hip -> /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_bwd_runner_grouped_hdim64_fp16_causal_gfx9x_hip.hip [ok]
      /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_fwd_runner_grouped_hdim128_bf16_noncausal_gfx9x.hip -> /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_fwd_runner_grouped_hdim128_bf16_noncausal_gfx9x_hip.hip [ok]
      /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_bwd_runner_batched_hdim32_fp16_noncausal_gfx9x.hip -> /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_bwd_runner_batched_hdim32_fp16_noncausal_gfx9x_hip.hip [ok]
      /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_fwd_runner_batched_hdim32_bf16_noncausal_gfx9x.hip -> /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_fwd_runner_batched_hdim32_bf16_noncausal_gfx9x_hip.hip [ok]
      /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_fwd_runner_grouped_hdim32_fp16_causal_gfx9x.hip -> /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_fwd_runner_grouped_hdim32_fp16_causal_gfx9x_hip.hip [ok]
      /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_bwd_runner_batched_hdim128_fp16_noncausal_gfx9x.hip -> /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_bwd_runner_batched_hdim128_fp16_noncausal_gfx9x_hip.hip [ok]
      /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_fwd_runner_batched_hdim64_fp16_noncausal_gfx9x.hip -> /tmp/tmp.lCILR94CYX/flash-attention/csrc/flash_attn_rocm/src/flash_fwd_runner_batched_hdim64_fp16_noncausal_gfx9x_hip.hip [ok]
      Successfully preprocessed all matching files.
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/tmp.lCILR94CYX/flash-attention/setup.py", line 312, in <module>
          setup(
        File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/setuptools/__init__.py", line 106, in setup
          _install_setup_requires(attrs)
        File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/setuptools/__init__.py", line 74, in _install_setup_requires
          dist = MinimalDistribution(attrs)
        File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/setuptools/__init__.py", line 56, in __init__
          super().__init__(filtered)
        File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/setuptools/dist.py", line 484, in __init__
          for ep in metadata.entry_points(group='distutils.setup_keywords'):
        File "/opt/conda/envs/py_3.10/lib/python3.10/importlib/metadata/__init__.py", line 1021, in entry_points
          return SelectableGroups.load(eps).select(**params)
        File "/opt/conda/envs/py_3.10/lib/python3.10/importlib/metadata/__init__.py", line 459, in load
          ordered = sorted(eps, key=by_group)
        File "/opt/conda/envs/py_3.10/lib/python3.10/importlib/metadata/__init__.py", line 1018, in <genexpr>
          eps = itertools.chain.from_iterable(
        File "/opt/conda/envs/py_3.10/lib/python3.10/importlib/metadata/_itertools.py", line 16, in unique_everseen
          k = key(element)
      AttributeError: 'PathDistribution' object has no attribute '_normalized_name'
      Total number of unsupported CUDA function calls: 0

      Total number of replaced kernel launches: 1
      Status update was skipped for remote run 97168ec9-e9eb-4a6a-9753-fcf329573c65
donglixp commented 10 months ago

possible solution: pip uninstall importlib-metadata and then rerun the pip install ..

donglixp commented 10 months ago
cd $(mktemp -d)
git clone --recursive https://github.com/ROCmSoftwarePlatform/flash-attention.git
export GPU_ARCHS="gfx90a"
cd flash-attention
export PYTHON_SITE_PACKAGES=$(python -c 'import site; print(site.getsitepackages()[0])')
patch "${PYTHON_SITE_PACKAGES}/torch/utils/hipify/hipify_python.py" hipify_patch.patch
pip uninstall importlib-metadata
pip install .
pip install importlib-metadata==3.4.0
jayz0123 commented 10 months ago

Hi @donglixp, is this bug fixed?

donglixp commented 10 months ago

I manually uninstall importlib-metadata to resolve the issue.