Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ ENV UV_LINK_MODE=copy
# Verify GCC version
RUN gcc --version

# Ensure CUDA compatibility library is loaded
RUN echo "/usr/local/cuda-$(echo "$CUDA_VERSION" | cut -d. -f1,2)/compat/" > /etc/ld.so.conf.d/cuda-compat.conf && ldconfig
# Ensure CUDA compatibility library is loaded at last to avoid overriding the system libraries
RUN echo "/usr/local/cuda-$(echo "$CUDA_VERSION" | cut -d. -f1,2)/compat/" > /etc/ld.so.conf.d/zzz-cuda-compat.conf && ldconfig
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While this change is correct, the command substitution $(echo "$CUDA_VERSION" | cut -d. -f1,2) to extract the major and minor CUDA version is repeated over 20 times in this Dockerfile. This makes the file hard to maintain and prone to errors if the logic needs to be updated.

To improve maintainability, consider defining variables for the different CUDA version formats at the beginning of the build stage and reusing them. A pattern for this already exists in this file for PYTHON_VERSION_STR (lines 499-500).

You could add a RUN command in the base stage (e.g., after line 121) to define and export these variables:

RUN echo "export CUDA_VERSION_SHORT=$(echo $CUDA_VERSION | cut -d. -f1,2)" >> /etc/environment && \
    echo "export CUDA_VERSION_NODOT=$(echo $CUDA_VERSION | cut -d. -f1,2 | tr -d '.')" >> /etc/environment && \
    echo "export CUDA_VERSION_DASH=$(echo $CUDA_VERSION | cut -d. -f1,2 | tr '.' '-')" >> /etc/environment

Then, you could source this file in subsequent RUN commands and use the variables. For example, this line would become:

RUN . /etc/environment && echo "/usr/local/cuda-${CUDA_VERSION_SHORT}/compat/" > /etc/ld.so.conf.d/zzz-cuda-compat.conf && ldconfig

Applying this pattern throughout the Dockerfile would significantly reduce redundancy and improve readability. A similar change would be needed in the vllm-base stage.


# ============================================================
# SLOW-CHANGING DEPENDENCIES BELOW
Expand Down Expand Up @@ -560,8 +560,8 @@ ENV UV_HTTP_TIMEOUT=500
ENV UV_INDEX_STRATEGY="unsafe-best-match"
ENV UV_LINK_MODE=copy

# Ensure CUDA compatibility library is loaded
RUN echo "/usr/local/cuda-$(echo "$CUDA_VERSION" | cut -d. -f1,2)/compat/" > /etc/ld.so.conf.d/cuda-compat.conf && ldconfig
# Ensure CUDA compatibility library is loaded at last to avoid overriding the system libraries
RUN echo "/usr/local/cuda-$(echo "$CUDA_VERSION" | cut -d. -f1,2)/compat/" > /etc/ld.so.conf.d/zzz-cuda-compat.conf && ldconfig
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the comment on line 136, this is another instance of repeated logic for CUDA version string manipulation. Applying the suggested refactoring in this vllm-base stage as well would improve maintainability. You can add a RUN command to define and export CUDA_VERSION_SHORT, CUDA_VERSION_NODOT, and CUDA_VERSION_DASH after Python installation (e.g., after line 537) and reuse them in subsequent commands.


# ============================================================
# SLOW-CHANGING DEPENDENCIES BELOW
Expand Down
Loading