Skip to content

Commit

Permalink
Test conda fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurie Germishuys committed Sep 27, 2024
1 parent 3d887c1 commit 61a0b04
Showing 1 changed file with 32 additions and 19 deletions.
51 changes: 32 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Build ffmpeg with CUDA support from source.
# Build the ffmpeg with CUDA support from source.
# We need ffmpeg on the system that works with the GPU.
# Only having the python package is not enough. ---
# To build from source we need the devel cuda image.
FROM nvcr.io/nvidia/cuda:12.0.1-cudnn8-devel-ubuntu20.04 as builder
# So that we are not asked for user input during the build
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
Expand All @@ -12,6 +16,7 @@ RUN apt-get update && \
libc6-dev \
libssl-dev \
libtool \
# The next package is needed to support -libx246 for ffmpeg
libx264-dev \
libxcb1-dev \
libxau-dev \
Expand All @@ -21,7 +26,7 @@ RUN apt-get update && \
apt-get clean

# --- Build ffmpeg with CUDA support from source ---
RUN git clone --depth 1 --branch n12.0.16.0 https://git.videolan.org/git/ffmpeg/nv-codec-headers.git && \
RUN git clone --depth 1 --branch n12.0.16.0 https://git.videolan.org/git/ffmpeg/nv-codec-headers.git && \
cd nv-codec-headers && \
make install && \
cd .. && \
Expand All @@ -34,6 +39,7 @@ RUN git clone --depth 1 --branch n12.0.16.0 https://git.videolan.org/git/ffmpeg/
--enable-openssl \
--disable-doc \
--disable-ffplay \
# The libx246 encoder is used in the project, therefore we need to enable libx246 and gpl
--enable-libx264 \
--enable-gpl \
--extra-cflags=-I/usr/local/cuda/include \
Expand All @@ -42,8 +48,12 @@ RUN git clone --depth 1 --branch n12.0.16.0 https://git.videolan.org/git/ffmpeg/
make install

# Start over from the docker image with cuda 12.0
# since we only want the final result from the previous run and we copy that.
# Now we can use the runtime cuda image, since we do not need to build anything
# from scratch. This is better, since the runtime image is smaller
FROM nvcr.io/nvidia/cuda:12.0.1-cudnn8-runtime-ubuntu20.04
COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
# So that we are not asked for user input during the build
ARG DEBIAN_FRONTEND=noninteractive

# Install dependencies
Expand All @@ -69,23 +79,8 @@ RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -
$HOME/miniconda/bin/conda config --set always_yes yes --set changeps1 no && \
$HOME/miniconda/bin/conda update -q conda && \
ln -s $HOME/miniconda/bin/conda /usr/local/bin/conda

# Set environment variables for user
ARG NB_USER=jovyan
ARG NB_UID=1000
ENV USER=${NB_USER} \
NB_UID=${NB_UID} \
HOME=/home/${NB_USER}

RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}

# Switch to the new user
USER ${NB_USER}

# Add Conda to PATH after the user is set

# Add Conda to PATH
ENV PATH="$HOME/miniconda/bin:$PATH"

# Create a working directory
Expand All @@ -103,12 +98,16 @@ RUN apt-get update && \
git \
vim && \
apt-get clean && \
# Install all python packages, numpy needs to be installed
# first to avoid the lap build error
python3 -m pip --no-cache-dir install --upgrade pip && \
python3 -m pip --no-cache-dir install numpy && \
python3 -m pip --no-cache-dir install \
-r /usr/src/app/kso/requirements.txt && \
# Uninstall OpenCV from pip and install it via conda
python3 -m pip uninstall -y opencv-python opencv-contrib-python && \
conda install -v -c conda-forge opencv && \
# Copy over custom autobackend file to enable use of older YOLO models
cp \
/usr/src/app/kso/src/autobackend.py \
/usr/local/lib/python3.8/dist-packages/ultralytics/nn/autobackend.py && \
Expand All @@ -121,3 +120,17 @@ ENV WANDB_DIR=/mimer/NOBACKUP/groups/snic2021-6-9/ \
DATA_DIR=/tmp \
ARTIFACT_DIR=/tmp \
PYTHONPATH=$PYTHONPATH:/usr/src/app/kso

# Set everything up to work with the jupyter notebooks
ARG NB_USER=jovyan
ARG NB_UID=1000
ENV USER=${NB_USER} \
NB_UID=${NB_UID} \
HOME=/home/${NB_USER}

RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}

USER ${NB_USER}

0 comments on commit 61a0b04

Please sign in to comment.