Skip to content

Commit

Permalink
Make the current dependencies and Docker image CPU-only
Browse files Browse the repository at this point in the history
Also makes it clear that this is a CPU-only setup
  • Loading branch information
ruksi committed Nov 19, 2024
1 parent ce2878e commit 29f5e23
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
.DS_Store
.idea
.valohai
Dockerfile
Dockerfile.cpu
40 changes: 40 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# CPU-Only Environments

## Dependencies

Resolve and lock CPU dependencies:

```bash
uv pip compile --extra-index-url https://download.pytorch.org/whl/cpu requirements.in -o requirements-cpu.txt
```

## Docker Image

Build the CPU-only Docker image:

```bash
docker build -f Dockerfile.cpu -t llm-toolkit:dev-cpu .
```

Smoke test the Docker image:

```bash
docker run -it --rm -v $(pwd):/workspace llm-toolkit:dev-cpu /bin/bash
python -c "import torch; print(torch.__version__)"
python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('we love you'))"
```

Release a new version of the CPU-only Docker image:

```bash
export LLM_TOOLKIT_VERSION=0.2-cpu
docker tag llm-toolkit:dev-cpu valohai/llm-toolkit:$LLM_TOOLKIT_VERSION
docker push valohai/llm-toolkit:$LLM_TOOLKIT_VERSION
```

Cleanup:

```bash
docker rmi valohai/llm-toolkit:$LLM_TOOLKIT_VERSION
docker rmi llm-toolkit:dev-cpu
```
8 changes: 0 additions & 8 deletions Dockerfile

This file was deleted.

15 changes: 15 additions & 0 deletions Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.11.10-bookworm

ENV PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_ROOT_USER_ACTION=ignore

WORKDIR /workspace

COPY requirements-cpu.txt .

RUN pip install \
--no-cache-dir \
--extra-index-url https://download.pytorch.org/whl/cpu \
-r requirements-cpu.txt \
&& rm requirements-cpu.txt
2 changes: 1 addition & 1 deletion requirements.txt → requirements-cpu.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.in -o requirements.txt
# uv pip compile requirements.in -o requirements-cpu.txt
accelerate==1.1.1
# via
# -r requirements.in
Expand Down
12 changes: 6 additions & 6 deletions valohai.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
- step:
name: data-preprocess
image: valohai/llm-toolkit:0.2
image: valohai/llm-toolkit:0.2-cpu
environment: trial2023-g4dn-xlarge
command:
- pip install -r requirements.txt
- pip install -r requirements-cpu.txt
- python data-preprocess.py {parameters}
parameters:
- name: tokenizer
Expand All @@ -21,10 +21,10 @@

- step:
name: finetune
image: valohai/llm-toolkit:0.2
image: valohai/llm-toolkit:0.2-cpu
environment: trial2023-g4dn-xlarge
command:
- pip install -r requirements.txt
- pip install -r requirements-cpu.txt
- python finetune-mistral.py {parameters}
parameters:
- name: base_mistral_model
Expand Down Expand Up @@ -57,10 +57,10 @@

- step:
name: inference
image: valohai/llm-toolkit:0.2
image: valohai/llm-toolkit:0.2-cpu
environment: trial2023-g4dn-xlarge
command:
- pip install -r requirements.txt
- pip install -r requirements-cpu.txt
- python inference-mistral.py {parameters}
parameters:
- name: base_mistral_model
Expand Down

0 comments on commit 29f5e23

Please sign in to comment.