Skip to content

Commit 1fbc34f

Browse files
Add Docker setup and example notebook for Ray Data LLM
1 parent 3a80450 commit 1fbc34f

File tree

6 files changed

+230
-0
lines changed

6 files changed

+230
-0
lines changed

docker/.dockerignore

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Python
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
*.so
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# Virtual Environment
28+
venv/
29+
.env
30+
.venv
31+
env/
32+
ENV/
33+
34+
# Docker
35+
docker/.dockerignore
36+
docker/Dockerfile
37+
docker/docker-compose.yml
38+
39+
# IDE
40+
.idea/
41+
.vscode/
42+
*.swp
43+
*.swo
44+
45+
# Ray
46+
/tmp/
47+
ray_bootstrap_key.pem
48+
ray_bootstrap_config.yaml
49+
50+
# Data and notebooks
51+
data/large_files/
52+
*.csv
53+
*.parquet
54+
*.arrow
55+
*.pkl
56+
*.h5
57+
.ipynb_checkpoints/
58+
59+
# Logs
60+
logs/
61+
*.log

docker/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM rayproject/ray:2.9.3-py310
2+
3+
# Set working directory
4+
WORKDIR /app
5+
6+
# Install additional Python dependencies
7+
RUN pip install --no-cache-dir \
8+
"ray[data]>=2.9.0" \
9+
vllm \
10+
pandas \
11+
numpy \
12+
torch \
13+
transformers \
14+
openai \
15+
tqdm \
16+
jupyterlab \
17+
jupyter \
18+
matplotlib \
19+
scikit-learn \
20+
huggingface_hub \
21+
datasets
22+
23+
# Copy requirements file if needed
24+
COPY requirements.txt /app/
25+
RUN pip install --no-cache-dir -r requirements.txt
26+
27+
# Copy project files to the container
28+
COPY . /app/
29+
30+
# Set environment variables
31+
ENV RAY_ADDRESS=auto
32+
33+
# Expose Ray ports
34+
EXPOSE 6379 8265 10001 8000 8888
35+
36+
# Default command
37+
CMD ["ray", "start", "--head", "--dashboard-host=0.0.0.0", "--port=6379", "--dashboard-port=8265", "--block"]

docker/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Docker Setup for Ray Data LLM
2+
3+
This directory contains Docker configuration files for running the Batch LLM Inference with Ray Data LLM project.
4+
5+
## Requirements
6+
7+
- Docker
8+
- Docker Compose
9+
- NVIDIA Container Toolkit (for GPU support)
10+
11+
## Quick Start
12+
13+
1. Build and start the containers:
14+
15+
```bash
16+
docker-compose up -d
17+
```
18+
19+
2. Access the Jupyter Lab interface:
20+
- Open your browser and navigate to `http://localhost:8888`
21+
- No password is required (configured for development)
22+
23+
3. Access the Ray Dashboard:
24+
- Open your browser and navigate to `http://localhost:8265`
25+
26+
## Configuration
27+
28+
The Docker setup includes:
29+
30+
- **ray-head**: The main Ray head node that coordinates all computation
31+
- **jupyter**: A Jupyter Lab environment connected to the Ray cluster
32+
33+
## GPU Support
34+
35+
The setup is configured to use GPUs if available. Make sure you have the NVIDIA Container Toolkit installed:
36+
37+
```bash
38+
# Check if NVIDIA Container Toolkit is installed
39+
sudo docker run --gpus all nvidia/cuda:11.8.0-base-ubuntu22.04 nvidia-smi
40+
```
41+
42+
## Data Persistence
43+
44+
Data is persisted through a Docker volume:
45+
46+
- **ray-data**: Stores Ray temporary data
47+
48+
## Customization
49+
50+
You can customize the setup by:
51+
52+
1. Modifying the `Dockerfile` to add additional dependencies
53+
2. Adjusting the `docker-compose.yml` file to change port mappings or resource allocations
54+
3. Updating the `requirements.txt` file to include specific package versions
55+
56+
## Troubleshooting
57+
58+
- If you encounter issues with GPU access, make sure your NVIDIA drivers and NVIDIA Container Toolkit are properly installed.
59+
- If Ray cannot access enough resources, try adjusting the memory and CPU allocations in the `docker-compose.yml` file.

docker/docker-compose.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version: '3.8'
2+
3+
services:
4+
ray-head:
5+
build:
6+
context: ..
7+
dockerfile: docker/Dockerfile
8+
container_name: ray-head
9+
ports:
10+
- "6379:6379" # Ray client port
11+
- "8265:8265" # Ray dashboard
12+
- "10001:10001" # Ray head node
13+
- "8000:8000" # For serving OpenAI-compatible API endpoints
14+
volumes:
15+
- ../:/app
16+
- ray-data:/tmp/ray
17+
environment:
18+
- RAY_ADDRESS=auto
19+
command: >
20+
ray start --head
21+
--dashboard-host=0.0.0.0
22+
--port=6379
23+
--dashboard-port=8265
24+
--block
25+
deploy:
26+
resources:
27+
reservations:
28+
devices:
29+
- driver: nvidia
30+
count: all
31+
capabilities: [gpu]
32+
33+
jupyter:
34+
build:
35+
context: ..
36+
dockerfile: docker/Dockerfile
37+
container_name: ray-jupyter
38+
ports:
39+
- "8888:8888" # Jupyter notebook
40+
volumes:
41+
- ../:/app
42+
- ray-data:/tmp/ray
43+
environment:
44+
- RAY_ADDRESS=ray://ray-head:10001
45+
depends_on:
46+
- ray-head
47+
command: jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root --NotebookApp.token='' --NotebookApp.password=''
48+
deploy:
49+
resources:
50+
reservations:
51+
devices:
52+
- driver: nvidia
53+
count: 1
54+
capabilities: [gpu]
55+
56+
volumes:
57+
ray-data:
58+
driver: local
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

requirements.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ray[data]>=2.9.0
2+
vllm>=0.2.0
3+
pandas>=2.0.0
4+
numpy>=1.23.0
5+
torch>=2.0.0
6+
transformers>=4.30.0
7+
openai>=1.0.0
8+
tqdm>=4.65.0
9+
jupyterlab>=4.0.0
10+
jupyter>=1.0.0
11+
matplotlib>=3.7.0
12+
scikit-learn>=1.2.0
13+
huggingface_hub>=0.16.0
14+
datasets>=2.12.0

0 commit comments

Comments
 (0)