Skip to content

Instantly share code, notes, and snippets.

@Martins6
Created July 13, 2023 20:30
Show Gist options
  • Save Martins6/8fde8d346b0c6088d8ad870364e31332 to your computer and use it in GitHub Desktop.
Save Martins6/8fde8d346b0c6088d8ad870364e31332 to your computer and use it in GitHub Desktop.
Dockerfile for building Ubuntu containers with NVIDIA drivers with Pytorch, transformes and other packages from the HuggingFace ecosystem installed (bitsandbytes included)
FROM nvidia/cuda:12.1.1-devel-ubuntu20.04
ARG DEBIAN_FRONTEND=noninteractive
# install git, python3.10 and pip
RUN apt-get update && apt-get install -y \
git \
curl \
software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt install -y python3.10 \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
# set and copy the project
COPY . /home/project
WORKDIR /home/project
# install poetry & install dependencies if your project has any
# to solve a bug
RUN python3.10 -m pip uninstall -y distro-info
RUN python3.10 -m pip install poetry
RUN python3.10 -m poetry config virtualenvs.create false
RUN python3.10 -m poetry install
# install pytorch
RUN python3.10 -m pip install --pre torch torchvision torchaudio \
--index-url https://download.pytorch.org/whl/nightly/cu121 \
&& python3.10 -m pip install bitsandbytes
# docker build -t nvidia-cuda-ubuntu -f nvidia_pytorch_ubuntu.dockerfile .
# docker container run -it --rm --gpus 1 nvidia-cuda-ubuntu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment