Skip to content

Commit

Permalink
Optimize Docker PyTorch for CUDA
Browse files Browse the repository at this point in the history
Enabled GPU acceleration for the PyTorch installation in the Dockerfile by specifying the CUDA version for the PyTorch wheels and by setting the RAG_EMBEDDING_MODEL_DEVICE_TYPE environment variable to use CUDA. This update resolves python requirements conflicts and ensures that machine learning models leverage the CUDA GPU processing capabilities, enhancing performance.

Refs #CUDAcompat, #DockerPerf
  • Loading branch information
yousecjoe committed Mar 21, 2024
1 parent 323d42e commit 4b03a8c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN npm run build
######## CUDA WebUI backend ########
FROM --platform=linux/amd64 nvidia/cuda:"$CUDA_VERSION"-devel-ubuntu22.04 AS cuda-build-amd64
#FROM --platform=linux/amd64 cgr.dev/chainguard/pytorch-cuda12:latest AS cuda-build-amd64 # fails with python requirements conflicts
ENV RAG_EMBEDDING_MODEL_DEVICE_TYPE="cuda"

# Set environment variables for NVIDIA Container Toolkit
ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64 \
Expand Down Expand Up @@ -85,7 +86,7 @@ RUN apk update && \
apk del /var/cache/apk/*.tbz2

COPY ./backend/requirements.txt ./requirements.txt
RUN pip3 install torch torchvision torchaudio --no-cache-dir && \
RUN pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 --no-cache-dir && \
pip3 install -r requirements.txt --no-cache-dir

# copy built frontend files
Expand Down

0 comments on commit 4b03a8c

Please sign in to comment.