Skip to content

Commit

Permalink
chore: improved cuda build
Browse files Browse the repository at this point in the history
  • Loading branch information
danellecline committed Aug 12, 2024
1 parent df6ebe4 commit 4757fe8
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.env
docs/
tests/
environment.yml
Dockerfile*
*.md
bin/
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "submodules/aidata"]
path = submodules/aidata
url = https://github.com/mbari-org/aidata
[submodule "src/submodules/aidata"]
path = src/submodules/aidata
url = https://github.com/mbari-org/aidata
35 changes: 19 additions & 16 deletions Dockerfile.cuda
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,33 @@ RUN apt-get update && apt-get install -y \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

ARG GITHUB_TOKEN
ARG GIT_VERSION=latest
ARG IMAGE_URI=mbari/fastapi-vss:${GIT_VERSION}

## setup virtualenv
ENV APP_HOME=/app
RUN pip install virtualenv
RUN virtualenv $APP_DIR/env -p python3
ENV VIRTUAL_ENV $APP_DIR/env
ENV PATH $APP_DIR/env/bin:$PATH
ENV PYTHONPATH=${APP_HOME}/fastapi-vss

ENV APP_HOME=/app
WORKDIR $APP_DIR/src/app
COPY ./src/requirements.txt $APP_DIR/src/requirements.txt
COPY ./src/app $APP_DIR/src/app
RUN git submodule update --init --recursive
ENV VIRTUAL_ENV $APP_HOME/env
ENV PATH $APP_HOME/env/bin:$PATH
ENV PYTHONPATH=${APP_HOME}/src:${APP_HOME}/src/submodules/aidata

WORKDIR $APP_HOME
COPY . .
WORKDIR $APP_HOME/src/submodules
RUN git clone https://${GITHUB_TOKEN}@github.com/mbari-org/aidata
ENV HF_HOME=/tmp/transformers_cache

WORKDIR $APP_HOME
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install -r requirements.txt && \
python3 -m pip install -r submodules/aidata/requirements.txt && \
python3 -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121

RUN chmod a+rwx -R $APP_DIR
python3 -m pip install -r src/requirements.txt && \
python3 -m pip install -r src/submodules/aidata/requirements.txt

# run the FastAPI server
EXPOSE 80
ENTRYPOINT ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
WORKDIR $APP_HOME/src/app
ENV PORT=80
EXPOSE ${PORT}
ENTRYPOINT ["sh", "-c", "exec uvicorn main:app --host 0.0.0.0 --port ${PORT} "]


13 changes: 4 additions & 9 deletions bin/run_prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"
BASE_DIR="$(cd "$(dirname "${SCRIPT_DIR}/../.." )" && pwd )"

# Export the environment variables in the .env file
export $(grep -v '^#' $BASE_DIR/.env | xargs)

# Get the short version of the hash of the commit
git_hash=$(git log -1 --format=%h)

# Get the user and group id
MLDEVOPS_UID=$(id -u)
MLDEVOPS_GID=$(id -g)

echo $MLDEVOPS_UID > .env
echo $MLDEVOPS_GID >> .env
echo MLDEVOPS_UID=$MLDEVOPS_UID >> .env
echo MLDEVOPS_GID=$MLDEVOPS_GID >> .env

# Run the production compose stack with the MLDEVOPS_UID and MLDEVOPS_GID
GIT_VERSION="${git_hash}" COMPOSE_PROJECT_NAME=fastapi-vss docker-compose -f compose.yml up -d --build --force-recreate --runtime nvidia --gpus all --no-deps -
#GIT_VERSION="${git_hash}" COMPOSE_PROJECT_NAME=fastapi-vss docker-compose -f compose.yml up -d --build --force-recreate --runtime nvidia --gpus all --no-deps -
echo COMPOSE_PROJECT_NAME=fastapi-vss docker-compose -f compose.yml up -d --build --force-recreate --runtime nvidia --gpus all --no-deps .
File renamed without changes.
1 change: 0 additions & 1 deletion src/submodules/aidata
Submodule aidata deleted from 51555c

0 comments on commit 4757fe8

Please sign in to comment.