Spaces:
Running
Running
| FROM nvidia/cuda:11.8.0-base-ubuntu22.04 | |
| # Remove any third-party apt sources to avoid issues with expiring keys. | |
| RUN rm -f /etc/apt/sources.list.d/*.list | |
| # Install some basic utilities. | |
| RUN apt-get update && apt-get install -y \ | |
| curl \ | |
| ca-certificates \ | |
| sudo \ | |
| git \ | |
| bzip2 \ | |
| libx11-6 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create a working directory. | |
| RUN mkdir /app | |
| WORKDIR /app | |
| # Create a non-root user and switch to it. | |
| RUN adduser --disabled-password --gecos '' --shell /bin/bash user \ | |
| && chown -R user:user /app | |
| RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user | |
| USER user | |
| # All users can use /home/user as their home directory. | |
| ENV HOME=/home/user | |
| RUN mkdir $HOME/.cache $HOME/.config \ | |
| && chmod -R 777 $HOME | |
| # Download and install Micromamba. | |
| RUN curl -sL https://micro.mamba.pm/api/micromamba/linux-64/1.1.0 \ | |
| | sudo tar -xvj -C /usr/local bin/micromamba | |
| ENV MAMBA_EXE=/usr/local/bin/micromamba \ | |
| MAMBA_ROOT_PREFIX=/home/user/micromamba \ | |
| CONDA_PREFIX=/home/user/micromamba \ | |
| PATH=/home/user/micromamba/bin:$PATH | |
| # Set up the base Conda environment by installing PyTorch and friends. | |
| COPY conda-linux-64.lock /app/conda-linux-64.lock | |
| RUN micromamba create -qy -n base -f /app/conda-linux-64.lock \ | |
| && rm /app/conda-linux-64.lock \ | |
| && micromamba shell init --shell=bash --prefix="$MAMBA_ROOT_PREFIX" \ | |
| && micromamba clean -qya | |
| # Fix for https://github.com/pytorch/pytorch/issues/97041 | |
| RUN ln -s "$CONDA_PREFIX/lib/libnvrtc.so.11.8.89" "$CONDA_PREFIX/lib/libnvrtc.so" | |
| WORKDIR /code | |
| COPY ./requirements.txt /code/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Set up a new user named "user" with user ID 1000 | |
| RUN useradd -m -u 1000 user | |
| # Switch to the "user" user | |
| USER user | |
| # Set home to the user's home directory | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set the working directory to the user's home directory | |
| WORKDIR $HOME/app | |
| # Copy the current directory contents into the container at $HOME/app setting the owner to the user | |
| COPY --chown=user . $HOME/app | |
| CMD ["python", "main.py"] |