Rate This Document
Findability
Accuracy
Completeness
Readability

Source Code Compilation and Build

Obtain the FlashAttention source code, build a wheel from the source code, and install the local build product.

  1. Obtain the FlashAttention 2.8.3 source code.
    1
    git clone --branch v2.8.3 --depth 1 https://github.com/Dao-AILab/flash-attention.git
    
  2. Ensure that PyTorch is a CUDA version.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    cd flash-attention
    python3 - <<'PY'
    import torch  
    
    print("torch_version=" + torch.__version__) 
    print("torch_cuda=" + str(torch.version.cuda)) 
    print("cuda_built=" + str(torch.backends.cuda.is_built())) 
    print("cuda_available=" + str(torch.cuda.is_available())) 
    assert torch.backends.cuda.is_built() 
    assert torch.cuda.is_available() 
    PY
    
  3. Build the wheel from the source code.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    export CUDA_HOME=/usr/local/cuda-13.0 
    export PATH=$CUDA_HOME/bin:$PATH
    export LD_LIBRARY_PATH=$CUDA_HOME/lib64:${LD_LIBRARY_PATH:-}
    export FLASH_ATTENTION_FORCE_BUILD=TRUE 
    export FLASH_ATTN_CUDA_ARCHS=80 
    export MAX_JOBS=8 
    export NVCC_THREADS=1  
    
    python3 -m pip wheel --no-build-isolation --no-deps --wheel-dir dist .
    
  4. Install the local build product.
    1
    python3 -m pip install --force-reinstall --no-deps dist/flash_attn-2.8.3-*.whl
    
    The following is an example of the build product.
    1
    flash_attn-2.8.3-cp311-cp311-linux_aarch64.whl