Skip to content

Commit

Permalink
fix: set workdir to models and specify entrypoint explicitly.
Browse files Browse the repository at this point in the history
* Fix bug with git to fetch models, use wget instead

* Fix bug where workdir is kept as /models. Specify entrypoint explicitly.
  • Loading branch information
erickgalinkin authored Feb 18, 2025
1 parent 9a77f6f commit 6d5a20c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
12 changes: 6 additions & 6 deletions nemoguardrails/library/jailbreak_detection/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ FROM python:3.10-slim
# Install git and wget
RUN apt-get update && apt-get install -y git gcc g++ python3-dev wget && apt-get clean

# Predownload embedding-based jailbreak detection models, set environment variable for path
WORKDIR /models
RUN wget https://huggingface.co/nvidia/NemoGuard-JailbreakDetect/resolve/main/snowflake.pkl
ENV EMBEDDING_CLASSIFIER_PATH=/models

# Set working directory
WORKDIR /app

Expand All @@ -21,14 +26,9 @@ ENV JAILBREAK_CHECK_DEVICE=cpu
# Predownload the GPT2 model.
RUN python -c "from transformers import GPT2LMHeadModel, GPT2TokenizerFast; GPT2LMHeadModel.from_pretrained('gpt2-large'); GPT2TokenizerFast.from_pretrained('gpt2-large');"

# Predownload embedding-based jailbreak detection models, set environment variable for path
WORKDIR /models
RUN wget https://huggingface.co/nvidia/NemoGuard-JailbreakDetect/resolve/main/snowflake.pkl
ENV EMBEDDING_CLASSIFIER_PATH=/models

# Expose a port for the server
EXPOSE 1337

# Start the server as the default command
ENTRYPOINT ["/usr/local/bin/python", "server.py"]
ENTRYPOINT ["/usr/local/bin/python", "/app/server.py"]
CMD ["--port=1337"]
21 changes: 9 additions & 12 deletions nemoguardrails/library/jailbreak_detection/Dockerfile-GPU
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ RUN apt-get install python3 python3-pip python3-dev -y
# Upgrade pip
RUN pip install --no-cache-dir --upgrade pip

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

# Predownload embedding-based jailbreak detection models, set environment variable for path
WORKDIR /models
RUN wget https://huggingface.co/nvidia/NemoGuard-JailbreakDetect/resolve/main/snowflake.pkl
ENV EMBEDDING_CLASSIFIER_PATH=/models

# Set working directory
WORKDIR /app

Expand All @@ -24,20 +32,9 @@ COPY . .
# Predownload the GPT2 model.
RUN python3 -c "from transformers import GPT2LMHeadModel, GPT2TokenizerFast; GPT2LMHeadModel.from_pretrained('gpt2-large'); GPT2TokenizerFast.from_pretrained('gpt2-large');"

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

# Predownload embedding-based jailbreak detection models, set environment variable for path
WORKDIR /models
RUN wget https://huggingface.co/nvidia/NemoGuard-JailbreakDetect/resolve/main/snowflake.pkl
ENV EMBEDDING_CLASSIFIER_PATH=/models

# To use nvidia/nv-embedqa-e5-v5 model, uncomment the line below and set your API key
# ENV NVIDIA_API_KEY=<your_api_key>

# Expose a port for the server
EXPOSE 1337

# Start the server as the default command
ENTRYPOINT ["/usr/local/bin/python", "server.py"]
ENTRYPOINT ["/usr/local/bin/python", "/app/server.py"]
CMD ["--port=1337"]

0 comments on commit 6d5a20c

Please sign in to comment.