Skip to content

Commit

Permalink
feat: Clover
Browse files Browse the repository at this point in the history
  • Loading branch information
jonafeucht committed Nov 9, 2024
1 parent 5ad99d2 commit 3b26673
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 8 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/dev.opencl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ jobs:
include:
- docker_file: Dockerfile.opencl.nvidia
label: "dev-opencl-nvidia"
- docker_file: Dockerfile.opencl.amd
label: "dev-opencl-amd"
- docker_file: Dockerfile.opencl.amd.rusticl
label: "dev-opencl-amd-rusticl"
- docker_file: Dockerfile.opencl.amd.clover
label: "dev-opencl-amd-clover"

steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/prod.opencl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ jobs:
include:
- docker_file: Dockerfile.opencl.nvidia
label: "latest-opencl-nvidia"
- docker_file: Dockerfile.opencl.amd
label: "latest-opencl-amd"
- docker_file: Dockerfile.opencl.amd.rusticl
label: "latest-opencl-amd-rusticl"
- docker_file: Dockerfile.opencl.amd.clover
label: "latest-opencl-amd-clover"

steps:
- uses: actions/checkout@v4
Expand Down
83 changes: 83 additions & 0 deletions Dockerfile.opencl.amd.clover
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
FROM ubuntu:noble

ARG DEBIAN_FRONTEND=noninteractive

USER root

ARG PYTORCH_OCL_VERSION=0.2.0
ARG TORCH_VERSION=2.4
ARG PYTHON_VERSION=cp312
ARG PLATFORM=linux_x86_64

ENV WHL_FILE=pytorch_ocl-${PYTORCH_OCL_VERSION}+torch${TORCH_VERSION}-${PYTHON_VERSION}-none-${PLATFORM}.whl
ENV WHL_URL=https://github.com/artyom-beilis/pytorch_dlprim/releases/download/${PYTORCH_OCL_VERSION}/${WHL_FILE}

WORKDIR /app
COPY . /app

RUN apt-get update && \
apt install software-properties-common -y && \
add-apt-repository ppa:kisak/kisak-mesa -y && \
apt-get update -y && \
apt dist-upgrade -y && \
apt-get install -y \
wget \
software-properties-common \
apt-transport-https \
ca-certificates \
curl \
gpg && \
rm -rf /var/lib/apt/lists/*

# Install OpenCL dependencies
RUN apt-get update && apt-get install -y \
ocl-icd-opencl-dev \
opencl-headers \
ocl-icd-libopencl1 \
clinfo \
mesa-opencl-icd \
&& rm -rf /var/lib/apt/lists/*

# Install Python 3.12
RUN add-apt-repository ppa:deadsnakes/ppa -y && \
apt-get update && \
apt-get install -y \
python3.12 \
python3.12-venv \
python3.12-dev \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

# Set up Python virtual environment
RUN python3.12 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
RUN pip install --upgrade pip

# Configure OpenCL vendors
RUN mkdir -p /etc/OpenCL/vendors && \
echo "libMesaOpenCL.so.1" > /etc/OpenCL/vendors/mesa.icd && \
chmod 755 /etc/OpenCL/vendors

RUN groupadd -f render && groupadd -f video
RUN usermod -a -G render,video root

RUN mkdir -p /dev/dri && \
touch /dev/dri/renderD128 && \
chmod 666 /dev/dri/renderD128

RUN chmod 666 /dev/dri/render* || true
RUN chmod 666 /dev/dri/card* || true

# Set environment variables for OpenCL
ENV OCL_ICD_VENDORS="/etc/OpenCL/vendors"
ENV OPENCL_VENDOR_PATH="/etc/OpenCL/vendors"

COPY requirements.txt /app/requirements.txt
RUN /app/venv/bin/pip install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu

# Install OpenCL backend for PyTorch
RUN wget ${WHL_URL} && \
/app/venv/bin/pip install ${WHL_FILE} && \
rm ${WHL_FILE}

CMD ["/app/venv/bin/python", "-m", "fastapi", "run", "main.py", "--proxy-headers", "--host", "0.0.0.0", "--port", "8000"]
File renamed without changes.
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,43 @@ services:
### **AMD GPU Support**
> [!WARNING]
> Unless AMD starts to officially support older Cards again (e.g. gfx803), ROCm will not be available.
> Unless AMD starts to officially support older Cards again (e.g. gfx8), ROCm will not be available.
**OpenCL (AMD64):**
**OpenCL Rusticl (AMD64):**
> [!CAUTION]
> While Rusticl is compatible with Polaris, there are significant differences in inference performance, with Polaris cards running Clover showing higher accuracy.
```yml
services:
image_video_classification_cuda:
image: ghcr.io/doppeltilde/image_video_classification:latest-opencl-amd-rusticl
ports:
- "8000:8000"
volumes:
- ./models:/root/.cache/huggingface/hub:rw
- /tmp/.X11-unix:/tmp/.X11-unix
environment:
- DEFAULT_MODEL_NAME
- BATCH_SIZE
- ACCESS_TOKEN
- DEFAULT_SCORE
- USE_API_KEYS
- API_KEYS
restart: unless-stopped
devices:
- /dev/kfd
- /dev/dri
security_opt:
- seccomp:unconfined
group_add:
- "video"
- "render"
```
**OpenCL Clover (AMD64):**
```yml
services:
image_video_classification_cuda:
image: ghcr.io/doppeltilde/image_video_classification:latest-opencl-amd
image: ghcr.io/doppeltilde/image_video_classification:latest-opencl-amd-clover
ports:
- "8000:8000"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.dev.opencl.amd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
opencl_amd_dev:
build:
context: .
dockerfile: ./Dockerfile.opencl.amd
dockerfile: ./Dockerfile.opencl.amd.rusticl
ports:
- "8200:8000"
environment:
Expand Down

0 comments on commit 3b26673

Please sign in to comment.