-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ad99d2
commit 3b26673
Showing
6 changed files
with
125 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters