Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not store pip cache during docker build #463

Merged
Merged
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ RUN apt-get install -y gcc g++
# Copy and install NeMo Guardrails
WORKDIR /nemoguardrails
COPY . /nemoguardrails
RUN pip install -e .[all]

# Remove the PIP cache
RUN rm -rf /root/.cache/pip
RUN pip install --no-cache-dir -e .[all]

# Make port 8000 available to the world outside this container
EXPOSE 8000
Expand Down
11 changes: 7 additions & 4 deletions nemoguardrails/library/factchecking/align_score/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ WORKDIR /app
# Clone and install the alignscore package
RUN git clone https://github.com/yuh-zha/AlignScore.git
WORKDIR /app/AlignScore
RUN pip install .
RUN pip install --no-cache-dir .

# Download the Spacy en_core_web_sm model
RUN python -m spacy download en_core_web_sm
Expand All @@ -24,11 +24,14 @@ RUN curl -OL https://huggingface.co/yzha/AlignScore/resolve/main/AlignScore-base
# Switch
WORKDIR /app

# Copy the source code
COPY . /app
# Copy requirements.txt
COPY requirements.txt .

# Install the minimal set of requirements for AlignScore Server
RUN pip install -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copy the source code
COPY . .

# Download the punkt model to speed up start time
RUN python -c "import nltk; nltk.download('punkt')"
Expand Down
17 changes: 8 additions & 9 deletions nemoguardrails/library/jailbreak_detection/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
FROM python:3.10-slim

# Install git
RUN apt-get update && apt-get install -y git && apt-get install gcc -y && apt-get install g++ -y && apt-get install python3-dev -y && apt-get clean

# Upgrade pip
RUN pip install --upgrade pip

# Copy the source code
COPY . /app
RUN apt-get update && apt-get install -y git gcc g++ python3-dev && apt-get clean

# Set working directory
WORKDIR /app

# Install the minimal set of requirements for jailbreak detection Server
RUN pip install -r requirements.txt
# Copy only requirements.txt
COPY requirements.txt .

# Upgrade pip and install the minimal set of requirements for jailbreak detection Server
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt

COPY . .

# Set the device on which the model should load e.g., "cpu", "cuda:0", etc.
ENV JAILBREAK_CHECK_DEVICE=cpu
Expand Down
20 changes: 11 additions & 9 deletions nemoguardrails/library/jailbreak_detection/Dockerfile-GPU
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@
FROM nvidia/cuda:12.3.1-base-ubuntu20.04

# Install git
RUN apt-get update && apt-get install -y git && apt-get install gcc -y && apt-get install g++ -y && apt-get clean
RUN apt-get update && apt-get install -y git gcc g++ && apt-get clean

# Install python
RUN apt-get install python3 python3-pip python3-dev -y

# Upgrade pip
RUN pip install --upgrade pip

# Copy the source code
COPY . /app
RUN pip install --no-cache-dir --upgrade pip

# Set working directory
WORKDIR /app

# Copy the source code
COPY requirements.txt .

# Install the minimal set of requirements for jailbreak detection Server
RUN pip install -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Predownload the GPT2 model.
RUN python3 -c "from transformers import GPT2LMHeadModel, GPT2TokenizerFast; GPT2LMHeadModel.from_pretrained('gpt2-large'); GPT2TokenizerFast.from_pretrained('gpt2-large');"
drazvan marked this conversation as resolved.
Show resolved Hide resolved

COPY . .

# Set the device on which the model should load e.g., "cpu", "cuda:0", etc.
ENV JAILBREAK_CHECK_DEVICE=cuda:0

# Predownload the GPT2 model.
RUN python -c "from transformers import GPT2LMHeadModel, GPT2TokenizerFast; GPT2LMHeadModel.from_pretrained('gpt2-large'); GPT2TokenizerFast.from_pretrained('gpt2-large');"

# Expose a port for the server
EXPOSE 1337

Expand Down