-
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
2636c9b
commit 5794ef0
Showing
4 changed files
with
33 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
FROM python:3.12.7 | ||
|
||
ENV DEBIAN_FRONTEND="noninteractive" | ||
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} | ||
|
||
ENV NVIDIA_VISIBLE_DEVICES all | ||
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility | ||
|
||
WORKDIR /app | ||
|
||
RUN apt update && \ | ||
apt full-upgrade -y && \ | ||
apt install python3 python3-dev git ocl-icd-opencl-dev opencl-clhpp-headers opencl-c-headers ocl-icd-libopencl1 clinfo -y && \ | ||
pip3 install --upgrade pip | ||
apt install python3 python3-full python3-pip python3-venv git wget ocl-icd-opencl-dev opencl-clhpp-headers opencl-c-headers opencl-headers ocl-icd-libopencl1 clinfo -y && \ | ||
python3 -m venv /app/venv && \ | ||
/app/venv/bin/pip install --upgrade pip | ||
|
||
COPY requirements.txt /app/requirements.txt | ||
RUN pip3 install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu | ||
|
||
# Install OpenCL backend for PyTorch | ||
RUN wget https://github.com/artyom-beilis/pytorch_dlprim/releases/download/0.2.0/pytorch_ocl-0.2.0+torch2.5-cp312-none-linux_x86_64.whl && \ | ||
pip3 install pytorch_ocl-0.2.0+torch2.5-cp312-none-linux_x86_64.whl && \ | ||
rm pytorch_ocl-0.2.0+torch2.5-cp312-none-linux_x86_64.whl | ||
|
||
# Install Nvidia OpenCL drivers | ||
# Configure OpenCL ICD loaders | ||
RUN mkdir -p /etc/OpenCL/vendors && \ | ||
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd | ||
ENV NVIDIA_VISIBLE_DEVICES all | ||
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,display | ||
|
||
RUN rm -f /etc/OpenCL/vendors/mesa.icd | ||
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} | ||
|
||
COPY . /app | ||
|
||
CMD ["fastapi", "run", "main.py", "--proxy-headers", "--host", "0.0.0.0", "--port", "8000"] | ||
CMD ["/app/venv/bin/python", "-m", "fastapi", "run", "main.py", "--proxy-headers", "--host", "0.0.0.0", "--port", "8000"] |
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