mirror of
				https://github.com/hiyouga/LLaMA-Factory.git
				synced 2025-11-04 18:02:19 +08:00 
			
		
		
		
	Add dockerize support
Already tested with the model of Qwen:1.8B and the dataset of alpaca_data_zh. Some python libraries are added to the Dockerfile as a result of the exception messages displayed throughout test procedure. Former-commit-id: 897e083bc28ccb15c46909b9d13fc03a674fb254
This commit is contained in:
		
							parent
							
								
									d46c2bbcba
								
							
						
					
					
						commit
						6169df1c52
					
				
							
								
								
									
										11
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
.vscode
 | 
			
		||||
.git
 | 
			
		||||
.github
 | 
			
		||||
.venv
 | 
			
		||||
cache
 | 
			
		||||
data
 | 
			
		||||
examples
 | 
			
		||||
.dockerignore
 | 
			
		||||
.gitattributes
 | 
			
		||||
.gitignore
 | 
			
		||||
Dockerfile
 | 
			
		||||
							
								
								
									
										15
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
FROM cnstark/pytorch:2.0.1-py3.9.17-cuda11.8.0-ubuntu20.04
 | 
			
		||||
 | 
			
		||||
WORKDIR /app
 | 
			
		||||
 | 
			
		||||
COPY requirements.txt /app/
 | 
			
		||||
RUN pip install -r requirements.txt && \
 | 
			
		||||
    pip install tiktoken && \
 | 
			
		||||
    pip install transformers_stream_generator
 | 
			
		||||
 | 
			
		||||
COPY . /app/
 | 
			
		||||
 | 
			
		||||
VOLUME [ "/root/.cache/huggingface/", "/app/data", "/app/output" ]
 | 
			
		||||
EXPOSE 7860
 | 
			
		||||
 | 
			
		||||
CMD [ "python", "src/train_web.py" ]
 | 
			
		||||
							
								
								
									
										26
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								README.md
									
									
									
									
									
								
							@ -648,6 +648,32 @@ CUDA_VISIBLE_DEVICES=0 python src/train_bash.py \
 | 
			
		||||
> [!TIP]
 | 
			
		||||
> We recommend using `--per_device_eval_batch_size=1` and `--max_target_length 128` at 4/8-bit predict.
 | 
			
		||||
 | 
			
		||||
### Dockerize Training
 | 
			
		||||
 | 
			
		||||
#### Get ready
 | 
			
		||||
 | 
			
		||||
Necessary dockerized environment is needed, such as Docker or Docker Compose.
 | 
			
		||||
 | 
			
		||||
#### Docker support
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
docker build -f ./Dockerfile -t llama-factory:latest .
 | 
			
		||||
 | 
			
		||||
docker run --gpus=all -v ./hf_cache:/root/.cache/huggingface/ -v ./data:/app/data -v ./output:/app/output -p 7860:7860 --shm-size 16G --name llama_factory -d llama-factory:latest
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
#### Docker Compose support
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
docker compose -f ./docker-compose.yml up -d
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
> [!TIP]
 | 
			
		||||
> Details about volume:
 | 
			
		||||
> * hf_cache: Utilize Huggingface cache on the host machine. Reassignable if a cache already exists in a different directory.
 | 
			
		||||
> * data: Place datasets on this dir of the host machine so that they can be selected on LLaMA Board GUI.
 | 
			
		||||
> * output: Set export dir to this location so that the merged result can be accessed directly on the host machine.
 | 
			
		||||
 | 
			
		||||
## Projects using LLaMA Factory
 | 
			
		||||
 | 
			
		||||
1. Wang et al. ESRL: Efficient Sampling-based Reinforcement Learning for Sequence Generation. 2023. [[arxiv]](https://arxiv.org/abs/2308.02223)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										23
									
								
								docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
			
		||||
version: '3.8'
 | 
			
		||||
 | 
			
		||||
services:
 | 
			
		||||
  llama-factory:
 | 
			
		||||
    build:
 | 
			
		||||
      dockerfile: Dockerfile
 | 
			
		||||
      context: .
 | 
			
		||||
    container_name: llama_factory
 | 
			
		||||
    volumes:
 | 
			
		||||
      - ./hf_cache:/root/.cache/huggingface/
 | 
			
		||||
      - ./data:/app/data
 | 
			
		||||
      - ./output:/app/output
 | 
			
		||||
    ports:
 | 
			
		||||
      - "7860:7860"
 | 
			
		||||
    shm_size: 16G
 | 
			
		||||
    deploy:
 | 
			
		||||
      resources:
 | 
			
		||||
        reservations:
 | 
			
		||||
          devices:
 | 
			
		||||
          - driver: nvidia
 | 
			
		||||
            count: "all"
 | 
			
		||||
            capabilities: [gpu]
 | 
			
		||||
    restart: unless-stopped
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user