|
|
VENV ?= venv |
|
|
PYTHON ?= $(VENV)/bin/python3 |
|
|
UVICORN ?= $(VENV)/bin/uvicorn |
|
|
DOCKER ?= docker |
|
|
IMAGE ?= safe-challenge-2025/example-submission |
|
|
GID ?= $(shell id -g) |
|
|
UID ?= $(shell id -u) |
|
|
|
|
|
.PHONY: setup |
|
|
setup: $(VENV)/requirements.cpu.txt |
|
|
|
|
|
.PHONY: download |
|
|
download: |
|
|
bash scripts/model_download.bash |
|
|
|
|
|
.PHONY: serve |
|
|
serve: |
|
|
$(UVICORN) main:app |
|
|
|
|
|
.PHONY: docker-build |
|
|
docker-build: |
|
|
docker build -t $(IMAGE) . |
|
|
|
|
|
.PHONY: docker-run |
|
|
docker-run: |
|
|
docker run --rm -it -p 8000:8000 $(IMAGE) |
|
|
|
|
|
.PHONY: compile |
|
|
compile: |
|
|
uv pip compile --python-version 3.12 --upgrade -o requirements.torch.cpu.txt.tmp requirements.torch.cpu.in |
|
|
echo "--index-url https://download.pytorch.org/whl/cpu" > requirements.torch.cpu.txt |
|
|
grep -e '^torch' requirements.torch.cpu.txt.tmp >> requirements.torch.cpu.txt |
|
|
uv pip compile --python-version 3.12 --upgrade -o requirements.cpu.txt requirements.cpu.in |
|
|
|
|
|
.PHONY: compile-gpu |
|
|
compile-gpu: |
|
|
uv pip compile --python-version 3.12 --upgrade -o requirements.torch.gpu.txt requirements.torch.gpu.in |
|
|
|
|
|
.PHONY: docker-build-gpu |
|
|
docker-build-gpu: |
|
|
docker build -t $(IMAGE)-gpu -f Dockerfile.gpu . |
|
|
|
|
|
requirements.cpu.txt: requirements.in requirements.torch.cpu.txt | $(VENV) |
|
|
uv pip compile --python-version 3.12 --upgrade -o requirements.cpu.txt requirements.cpu.in |
|
|
|
|
|
requirements.torch.cpu.txt: requirements.torch.cpu.in | $(VENV) |
|
|
uv pip compile --python-version 3.12 --upgrade -o requirements.torch.cpu.txt.tmp requirements.torch.cpu.in |
|
|
echo "--index-url https://download.pytorch.org/whl/cpu" > requirements.torch.cpu.txt |
|
|
cat requirements.torch.cpu.txt.tmp | grep '^torch' >> requirements.torch.cpu.txt |
|
|
|
|
|
$(VENV)/requirements.cpu.txt: requirements.cpu.txt | $(VENV) |
|
|
VIRTUAL_ENV=$(VENV) uv pip install -r requirements.cpu.txt |
|
|
VIRTUAL_ENV=$(VENV) uv pip install -r requirements.torch.cpu.txt |
|
|
cp -f requirements.cpu.txt $(VENV)/requirements.cpu.txt |
|
|
cp -f requirements.torch.cpu.txt $(VENV)/requirements.torch.cpu.txt |
|
|
|
|
|
$(VENV): |
|
|
uv venv $(VENV) |
|
|
|