mirror of
				https://github.com/hiyouga/LLaMA-Factory.git
				synced 2025-11-04 18:02:19 +08:00 
			
		
		
		
	Merge pull request #4461 from hzhaoy/feature/support-flash-attn
support flash-attn in Dockerfile Former-commit-id: e30a47ab5bda9303c8a2eb814caf0dd40c01b125
This commit is contained in:
		
						commit
						727c7b0dc6
					
				@ -444,6 +444,7 @@ docker build -f ./docker/docker-cuda/Dockerfile \
 | 
			
		||||
    --build-arg INSTALL_BNB=false \
 | 
			
		||||
    --build-arg INSTALL_VLLM=false \
 | 
			
		||||
    --build-arg INSTALL_DEEPSPEED=false \
 | 
			
		||||
    --build-arg INSTALL_FLASH_ATTN=false \
 | 
			
		||||
    --build-arg PIP_INDEX=https://pypi.org/simple \
 | 
			
		||||
    -t llamafactory:latest .
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -444,6 +444,7 @@ docker build -f ./docker/docker-cuda/Dockerfile \
 | 
			
		||||
    --build-arg INSTALL_BNB=false \
 | 
			
		||||
    --build-arg INSTALL_VLLM=false \
 | 
			
		||||
    --build-arg INSTALL_DEEPSPEED=false \
 | 
			
		||||
    --build-arg INSTALL_FLASH_ATTN=false \
 | 
			
		||||
    --build-arg PIP_INDEX=https://pypi.org/simple \
 | 
			
		||||
    -t llamafactory:latest .
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -6,6 +6,7 @@ FROM nvcr.io/nvidia/pytorch:24.02-py3
 | 
			
		||||
ARG INSTALL_BNB=false
 | 
			
		||||
ARG INSTALL_VLLM=false
 | 
			
		||||
ARG INSTALL_DEEPSPEED=false
 | 
			
		||||
ARG INSTALL_FLASH_ATTN=false
 | 
			
		||||
ARG PIP_INDEX=https://pypi.org/simple
 | 
			
		||||
 | 
			
		||||
# Set the working directory
 | 
			
		||||
@ -35,6 +36,13 @@ RUN EXTRA_PACKAGES="metrics"; \
 | 
			
		||||
    pip install -e .[$EXTRA_PACKAGES] && \
 | 
			
		||||
    pip uninstall -y transformer-engine flash-attn
 | 
			
		||||
 | 
			
		||||
# Rebuild flash-attn
 | 
			
		||||
RUN if [ "$INSTALL_FLASH_ATTN" = "true" ]; then \
 | 
			
		||||
        ninja --version || \
 | 
			
		||||
        (pip uninstall -y ninja && pip install ninja) && \
 | 
			
		||||
        MAX_JOBS=4 pip install --no-cache-dir flash-attn --no-build-isolation \
 | 
			
		||||
    fi;
 | 
			
		||||
 | 
			
		||||
# Set up volumes
 | 
			
		||||
VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/app/data", "/app/output" ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -7,6 +7,7 @@ services:
 | 
			
		||||
        INSTALL_BNB: false
 | 
			
		||||
        INSTALL_VLLM: false
 | 
			
		||||
        INSTALL_DEEPSPEED: false
 | 
			
		||||
        INSTALL_FLASH_ATTN: false
 | 
			
		||||
        PIP_INDEX: https://pypi.org/simple
 | 
			
		||||
    container_name: llamafactory
 | 
			
		||||
    volumes:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user