diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..795b99b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# Keep Linux shell scripts and container files on Unix line endings even when cloned on Windows. +*.sh text eol=lf +Dockerfile* text eol=lf +*.yml text eol=lf +*.yaml text eol=lf diff --git a/.github/workflows/gpu-static-check.yml b/.github/workflows/gpu-static-check.yml index 891d7ee..d27bd67 100644 --- a/.github/workflows/gpu-static-check.yml +++ b/.github/workflows/gpu-static-check.yml @@ -3,6 +3,7 @@ name: CPU/GPU direct-runner static check on: pull_request: paths: + - ".gitattributes" - "Dockerfile.cpu" - "Dockerfile.gpu" - "docker-compose.yml" @@ -18,6 +19,7 @@ on: push: branches: [main] paths: + - ".gitattributes" - "Dockerfile.cpu" - "Dockerfile.gpu" - "docker-compose.yml" @@ -77,25 +79,42 @@ jobs: cmp mock-release/lfm_aux.pt mock-downloaded/lfm_aux.pt cmp mock-release/lfm_dspark.pt mock-downloaded/lfm_dspark.pt - - name: Validate GPU shell entrypoint - run: bash -n scripts/test_gpu.sh + - name: Validate Linux shell entrypoint and line endings + run: | + bash -n scripts/test_gpu.sh + python - <<'PY' + from pathlib import Path + data = Path('scripts/test_gpu.sh').read_bytes() + assert b'\r\n' not in data, 'scripts/test_gpu.sh must be LF, not CRLF' + assert data.startswith(b'#!/usr/bin/env bash\n') + PY + grep -Fq '*.sh text eol=lf' .gitattributes + grep -Fq "sed -i 's/\\r$//' /app/scripts/test_gpu.sh" Dockerfile.gpu - name: Validate Docker Compose CPU and GPU services run: | docker compose --profile cpu --profile gpu config -q docker compose --profile cpu config --services | grep -qx test-cpu docker compose --profile gpu config --services | grep -qx test-gpu + docker compose --profile cpu config | grep -Fq 'image: dflash-mini-lab-test-cpu:latest' + docker compose --profile gpu config | grep -Fq 'image: dflash-mini-lab-test-gpu:latest' - name: Verify zero-install Docker paths run: | - grep -q 'torch torchvision' Dockerfile.cpu - grep -q 'download.pytorch.org/whl/cpu' Dockerfile.cpu - grep -q 'COPY run_gpu.py run_cpu.py' Dockerfile.cpu + # Keep the known-working Dockerfile installation style. Do not require + # version pins or a dedicated CPU wheel index for the CPU image. + grep -Fq 'python -m pip install torch torchvision' Dockerfile.cpu + grep -Fq 'python -m pip install numpy transformers' Dockerfile.cpu + grep -Fq 'COPY run_gpu.py run_cpu.py ./' Dockerfile.cpu ! grep -q 'pip install \.' Dockerfile.cpu - grep -q 'torch torchvision' Dockerfile.gpu - grep -q 'download.pytorch.org/whl/cu132' Dockerfile.gpu - grep -q 'COPY run_gpu.py' Dockerfile.gpu + + # GPU keeps the same style but must use the CUDA 13.2 wheel index. + grep -Fq 'python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cu132' Dockerfile.gpu + grep -Fq 'python -m pip install numpy transformers' Dockerfile.gpu + grep -Fq 'COPY run_gpu.py ./run_gpu.py' Dockerfile.gpu + ! grep -Fq 'pip install install' Dockerfile.gpu ! grep -q 'pip install \.' Dockerfile.gpu + grep -q 'gpus: all' docker-compose.yml grep -q 'test-cpu:' docker-compose.yml grep -q 'test-gpu:' docker-compose.yml diff --git a/Dockerfile.gpu b/Dockerfile.gpu index f4e7629..455e7ef 100644 --- a/Dockerfile.gpu +++ b/Dockerfile.gpu @@ -16,14 +16,18 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ WORKDIR /app RUN python -m pip install --upgrade pip \ - && python -m pip install install torch torchvision --index-url https://download.pytorch.org/whl/cu132 \ + && python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cu132 \ && python -m pip install numpy transformers COPY src ./src COPY real_benchmarks ./real_benchmarks COPY scripts ./scripts COPY run_gpu.py ./run_gpu.py -RUN chmod +x /app/scripts/test_gpu.sh + +# Windows checkouts can provide CRLF shell scripts. Normalize inside the Linux image +# as a second line of defense in addition to .gitattributes. +RUN sed -i 's/\r$//' /app/scripts/test_gpu.sh \ + && chmod +x /app/scripts/test_gpu.sh RUN mkdir -p /cache /app/lfm-artifacts /app/gpu-reports diff --git a/docker-compose.yml b/docker-compose.yml index b2ed04a..3b909c6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,7 @@ services: test-cpu: profiles: ["cpu"] + image: dflash-mini-lab-test-cpu:latest build: context: . dockerfile: Dockerfile.cpu @@ -41,6 +42,7 @@ services: test-gpu: profiles: ["gpu"] + image: dflash-mini-lab-test-gpu:latest build: context: . dockerfile: Dockerfile.gpu