update
This commit is contained in:
163
finetune/Dockerfile
Normal file
163
finetune/Dockerfile
Normal file
@@ -0,0 +1,163 @@
|
||||
FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu22.04
|
||||
|
||||
ARG DEBIAN_FRONTEND="noninteractive"
|
||||
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
|
||||
ENV MAMBA_ROOT_PREFIX=~/micromamba
|
||||
WORKDIR /root
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
# base tools
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
apt-get update
|
||||
apt-get install -y wget curl git jq vim bash libaio-dev build-essential openssh-server
|
||||
# Configure SSH for password and public key authentication
|
||||
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
|
||||
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
|
||||
echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
|
||||
echo "Port 22" >> /etc/ssh/sshd_config
|
||||
mkdir /var/run/sshd
|
||||
echo 'root:root' | chpasswd
|
||||
mkdir -p ~/.pip
|
||||
echo "
|
||||
[global]
|
||||
index-url = https://mirrors.aliyun.com/pypi/simple/
|
||||
|
||||
[install]
|
||||
trusted-host=mirrors.aliyun.com
|
||||
" >> ~/.pip/pip.conf
|
||||
EOT
|
||||
|
||||
# deepspeed
|
||||
ENV STAGE_DIR=/tmp
|
||||
|
||||
RUN <<EOT
|
||||
#!/bin/bash
|
||||
mkdir -p ${STAGE_DIR}
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends
|
||||
software-properties-common build-essential autotools-dev \
|
||||
nfs-common pdsh \
|
||||
cmake g++ gcc \
|
||||
curl wget vim tmux emacs less unzip \
|
||||
htop iftop iotop ca-certificates openssh-client openssh-server \
|
||||
rsync iputils-ping net-tools sudo \
|
||||
llvm-dev
|
||||
add-apt-repository ppa:git-core/ppa -y
|
||||
apt-get install -y git
|
||||
echo "ClientAliveInterval 30" >> /etc/ssh/sshd_config
|
||||
cp /etc/ssh/sshd_config ${STAGE_DIR}/sshd_config
|
||||
sed "0,/^#Port 22/s//Port 22/" ${STAGE_DIR}/sshd_config > /etc/ssh/sshd_config
|
||||
EOT
|
||||
|
||||
# Mellanox OFED
|
||||
ENV MLNX_OFED_VERSION=4.9-7.1.0.0
|
||||
RUN apt-get install -y libnuma-dev
|
||||
RUN cd ${STAGE_DIR} && \
|
||||
wget -q -O - http://www.mellanox.com/downloads/ofed/MLNX_OFED-${MLNX_OFED_VERSION}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu20.04-x86_64.tgz | tar xzf - && \
|
||||
cd MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu20.04-x86_64 && \
|
||||
./mlnxofedinstall --user-space-only --without-fw-update --all -q && \
|
||||
cd ${STAGE_DIR} && \
|
||||
rm -rf ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu20.04-x86_64*
|
||||
# nv_peer_mem
|
||||
ENV NV_PEER_MEM_VERSION=1.2
|
||||
ENV NV_PEER_MEM_TAG=${NV_PEER_MEM_VERSION}-0
|
||||
RUN mkdir -p ${STAGE_DIR} && \
|
||||
git clone https://github.com/Mellanox/nv_peer_memory.git --branch ${NV_PEER_MEM_TAG} ${STAGE_DIR}/nv_peer_memory && \
|
||||
cd ${STAGE_DIR}/nv_peer_memory && \
|
||||
./build_module.sh && \
|
||||
cd ${STAGE_DIR} && \
|
||||
tar xzf ${STAGE_DIR}/nvidia-peer-memory_${NV_PEER_MEM_VERSION}.orig.tar.gz && \
|
||||
cd ${STAGE_DIR}/nvidia-peer-memory-${NV_PEER_MEM_VERSION} && \
|
||||
apt-get update && \
|
||||
apt-get install -y dkms && \
|
||||
dpkg-buildpackage -us -uc && \
|
||||
dpkg -i ${STAGE_DIR}/nvidia-peer-memory_${NV_PEER_MEM_TAG}_all.deb
|
||||
# OPENMPI
|
||||
ENV OPENMPI_BASEVERSION=4.1
|
||||
ENV OPENMPI_VERSION=${OPENMPI_BASEVERSION}.6
|
||||
RUN cd ${STAGE_DIR} && \
|
||||
wget -q -O - https://download.open-mpi.org/release/open-mpi/v${OPENMPI_BASEVERSION}/openmpi-${OPENMPI_VERSION}.tar.gz | tar xzf - && \
|
||||
cd openmpi-${OPENMPI_VERSION} && \
|
||||
./configure --prefix=/usr/local/openmpi-${OPENMPI_VERSION} && \
|
||||
make -j"$(nproc)" install && \
|
||||
ln -s /usr/local/openmpi-${OPENMPI_VERSION} /usr/local/mpi && \
|
||||
# Sanity check:
|
||||
test -f /usr/local/mpi/bin/mpic++ && \
|
||||
cd ${STAGE_DIR} && \
|
||||
rm -r ${STAGE_DIR}/openmpi-${OPENMPI_VERSION}
|
||||
ENV PATH=/usr/local/mpi/bin:${PATH} \
|
||||
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/mpi/lib:/usr/local/mpi/lib64:${LD_LIBRARY_PATH}
|
||||
# Create a wrapper for OpenMPI to allow running as root by default
|
||||
RUN mv /usr/local/mpi/bin/mpirun /usr/local/mpi/bin/mpirun.real && \
|
||||
echo '#!/bin/bash' > /usr/local/mpi/bin/mpirun && \
|
||||
echo 'mpirun.real --allow-run-as-root --prefix /usr/local/mpi "$@"' >> /usr/local/mpi/bin/mpirun && \
|
||||
chmod a+x /usr/local/mpi/bin/mpirun
|
||||
# Python
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV PYTHON_VERSION=3
|
||||
RUN apt-get install -y python3 python3-dev && \
|
||||
rm -f /usr/bin/python && \
|
||||
ln -s /usr/bin/python3 /usr/bin/python && \
|
||||
curl -O https://bootstrap.pypa.io/pip/3.6/get-pip.py && \
|
||||
python get-pip.py && \
|
||||
rm get-pip.py && \
|
||||
pip install --upgrade pip && \
|
||||
# Print python an pip version
|
||||
python -V && pip -V
|
||||
RUN pip install pyyaml
|
||||
RUN pip install ipython
|
||||
# Some Packages
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libsndfile-dev \
|
||||
libcupti-dev \
|
||||
libjpeg-dev \
|
||||
libpng-dev \
|
||||
screen \
|
||||
libaio-dev
|
||||
RUN pip install psutil \
|
||||
yappi \
|
||||
cffi \
|
||||
ipdb \
|
||||
pandas \
|
||||
matplotlib \
|
||||
py3nvml \
|
||||
pyarrow \
|
||||
graphviz \
|
||||
astor \
|
||||
boto3 \
|
||||
tqdm \
|
||||
sentencepiece \
|
||||
msgpack \
|
||||
requests \
|
||||
pandas \
|
||||
sphinx \
|
||||
sphinx_rtd_theme \
|
||||
scipy \
|
||||
numpy \
|
||||
scikit-learn \
|
||||
nvidia-ml-py3 \
|
||||
mpi4py
|
||||
# PyTorch
|
||||
ARG PYTORCH_VERSION=1.13.0
|
||||
ENV PYTORCH_VERSION=${PYTORCH_VERSION}
|
||||
RUN pip install torch==${PYTORCH_VERSION}
|
||||
RUN rm -rf /usr/lib/python3/dist-packages/yaml && \
|
||||
rm -rf /usr/lib/python3/dist-packages/PyYAML-*
|
||||
## Add deepspeed user
|
||||
# Add a deepspeed user with user id 8877
|
||||
#RUN useradd --create-home --uid 8877 deepspeed
|
||||
RUN useradd --create-home --uid 1000 --shell /bin/bash deepspeed
|
||||
RUN usermod -aG sudo deepspeed
|
||||
RUN echo "deepspeed ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
# # Change to non-root privilege
|
||||
USER deepspeed
|
||||
# DeepSpeed
|
||||
RUN git clone https://github.com/microsoft/DeepSpeed.git ${STAGE_DIR}/DeepSpeed
|
||||
RUN cd ${STAGE_DIR}/DeepSpeed && \
|
||||
git checkout . && \
|
||||
git checkout master && \
|
||||
./install.sh --pip_sudo
|
||||
RUN rm -rf ${STAGE_DIR}/DeepSpeed
|
||||
RUN python -c "import deepspeed; print(deepspeed.__version__)"
|
||||
46
finetune/accelerate-gpu-deepspeed.Dockerfile
Normal file
46
finetune/accelerate-gpu-deepspeed.Dockerfile
Normal file
@@ -0,0 +1,46 @@
|
||||
# Builds GPU docker image of PyTorch specifically
|
||||
# Uses multi-staged approach to reduce size
|
||||
# Stage 1
|
||||
# Use base conda image to reduce time
|
||||
FROM continuumio/miniconda3:latest AS compile-image
|
||||
# Specify py version
|
||||
# Note: DeepSpeed beyond v0.12.6 requires py 3.10
|
||||
ENV PYTHON_VERSION=3.10
|
||||
# Install apt libs
|
||||
RUN apt-get update && \
|
||||
apt-get install -y curl git wget && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists*
|
||||
|
||||
# Create our conda env
|
||||
RUN conda create --name accelerate python=${PYTHON_VERSION} ipython jupyter pip
|
||||
# We don't install pytorch here yet since CUDA isn't available
|
||||
# instead we use the direct torch wheel
|
||||
ENV PATH /opt/conda/envs/accelerate/bin:$PATH
|
||||
# Activate our bash shell
|
||||
RUN chsh -s /bin/bash
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
# Activate the conda env, install mpy4pi, and install torch + accelerate
|
||||
RUN source activate accelerate && conda install -c conda-forge mpi4py
|
||||
RUN source activate accelerate && \
|
||||
python3 -m pip install --no-cache-dir \
|
||||
git+https://github.com/huggingface/accelerate#egg=accelerate[testing,test_trackers,deepspeed] \
|
||||
--extra-index-url https://download.pytorch.org/whl/cu117
|
||||
|
||||
RUN python3 -m pip install --no-cache-dir bitsandbytes
|
||||
|
||||
# Stage 2
|
||||
FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04 AS build-image
|
||||
COPY --from=compile-image /opt/conda /opt/conda
|
||||
ENV PATH /opt/conda/bin:$PATH
|
||||
|
||||
# Install apt libs
|
||||
RUN apt-get update && \
|
||||
apt-get install -y curl git wget && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists*
|
||||
|
||||
RUN echo "source activate accelerate" >> ~/.profile
|
||||
|
||||
# Activate the virtualenv
|
||||
CMD ["/bin/bash"]
|
||||
184
finetune/deepspeed.Dockerfile
Normal file
184
finetune/deepspeed.Dockerfile
Normal file
@@ -0,0 +1,184 @@
|
||||
FROM nvidia/cuda:12.2.2-devel-ubuntu20.04
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
##############################################################################
|
||||
# Temporary Installation Directory
|
||||
##############################################################################
|
||||
ENV STAGE_DIR=/tmp
|
||||
RUN mkdir -p ${STAGE_DIR}
|
||||
|
||||
##############################################################################
|
||||
# Installation/Basic Utilities
|
||||
##############################################################################
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
software-properties-common build-essential autotools-dev \
|
||||
nfs-common pdsh \
|
||||
cmake g++ gcc \
|
||||
curl wget vim tmux emacs less unzip \
|
||||
htop iftop iotop ca-certificates openssh-client openssh-server \
|
||||
rsync iputils-ping net-tools sudo \
|
||||
llvm-dev
|
||||
|
||||
##############################################################################
|
||||
# Installation Latest Git
|
||||
##############################################################################
|
||||
RUN add-apt-repository ppa:git-core/ppa -y && \
|
||||
apt-get update && \
|
||||
apt-get install -y git && \
|
||||
git --version
|
||||
|
||||
##############################################################################
|
||||
# Client Liveness & Uncomment Port 22 for SSH Daemon
|
||||
##############################################################################
|
||||
# Keep SSH client alive from server side
|
||||
RUN echo "ClientAliveInterval 30" >> /etc/ssh/sshd_config
|
||||
RUN cp /etc/ssh/sshd_config ${STAGE_DIR}/sshd_config && \
|
||||
sed "0,/^#Port 22/s//Port 22/" ${STAGE_DIR}/sshd_config > /etc/ssh/sshd_config
|
||||
|
||||
##############################################################################
|
||||
# Mellanox OFED
|
||||
##############################################################################
|
||||
ENV MLNX_OFED_VERSION=4.9-7.1.0.0
|
||||
RUN apt-get install -y libnuma-dev
|
||||
RUN cd ${STAGE_DIR} && \
|
||||
wget -q -O - http://www.mellanox.com/downloads/ofed/MLNX_OFED-${MLNX_OFED_VERSION}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu20.04-x86_64.tgz | tar xzf - && \
|
||||
cd MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu20.04-x86_64 && \
|
||||
./mlnxofedinstall --user-space-only --without-fw-update --all -q && \
|
||||
cd ${STAGE_DIR} && \
|
||||
rm -rf ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu20.04-x86_64*
|
||||
|
||||
##############################################################################
|
||||
# nv_peer_mem
|
||||
##############################################################################
|
||||
ENV NV_PEER_MEM_VERSION=1.2
|
||||
ENV NV_PEER_MEM_TAG=${NV_PEER_MEM_VERSION}-0
|
||||
RUN mkdir -p ${STAGE_DIR} && \
|
||||
git clone https://github.com/Mellanox/nv_peer_memory.git --branch ${NV_PEER_MEM_TAG} ${STAGE_DIR}/nv_peer_memory && \
|
||||
cd ${STAGE_DIR}/nv_peer_memory && \
|
||||
./build_module.sh && \
|
||||
cd ${STAGE_DIR} && \
|
||||
tar xzf ${STAGE_DIR}/nvidia-peer-memory_${NV_PEER_MEM_VERSION}.orig.tar.gz && \
|
||||
cd ${STAGE_DIR}/nvidia-peer-memory-${NV_PEER_MEM_VERSION} && \
|
||||
apt-get update && \
|
||||
apt-get install -y dkms && \
|
||||
dpkg-buildpackage -us -uc && \
|
||||
dpkg -i ${STAGE_DIR}/nvidia-peer-memory_${NV_PEER_MEM_TAG}_all.deb
|
||||
|
||||
##############################################################################
|
||||
# OPENMPI
|
||||
##############################################################################
|
||||
ENV OPENMPI_BASEVERSION=4.1
|
||||
ENV OPENMPI_VERSION=${OPENMPI_BASEVERSION}.6
|
||||
RUN cd ${STAGE_DIR} && \
|
||||
wget -q -O - https://download.open-mpi.org/release/open-mpi/v${OPENMPI_BASEVERSION}/openmpi-${OPENMPI_VERSION}.tar.gz | tar xzf - && \
|
||||
cd openmpi-${OPENMPI_VERSION} && \
|
||||
./configure --prefix=/usr/local/openmpi-${OPENMPI_VERSION} && \
|
||||
make -j"$(nproc)" install && \
|
||||
ln -s /usr/local/openmpi-${OPENMPI_VERSION} /usr/local/mpi && \
|
||||
# Sanity check:
|
||||
test -f /usr/local/mpi/bin/mpic++ && \
|
||||
cd ${STAGE_DIR} && \
|
||||
rm -r ${STAGE_DIR}/openmpi-${OPENMPI_VERSION}
|
||||
ENV PATH=/usr/local/mpi/bin:${PATH} \
|
||||
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/mpi/lib:/usr/local/mpi/lib64:${LD_LIBRARY_PATH}
|
||||
# Create a wrapper for OpenMPI to allow running as root by default
|
||||
RUN mv /usr/local/mpi/bin/mpirun /usr/local/mpi/bin/mpirun.real && \
|
||||
echo '#!/bin/bash' > /usr/local/mpi/bin/mpirun && \
|
||||
echo 'mpirun.real --allow-run-as-root --prefix /usr/local/mpi "$@"' >> /usr/local/mpi/bin/mpirun && \
|
||||
chmod a+x /usr/local/mpi/bin/mpirun
|
||||
|
||||
##############################################################################
|
||||
# Python
|
||||
##############################################################################
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV PYTHON_VERSION=3
|
||||
RUN apt-get install -y python3 python3-dev && \
|
||||
rm -f /usr/bin/python && \
|
||||
ln -s /usr/bin/python3 /usr/bin/python && \
|
||||
curl -O https://bootstrap.pypa.io/pip/3.6/get-pip.py && \
|
||||
python get-pip.py && \
|
||||
rm get-pip.py && \
|
||||
pip install --upgrade pip && \
|
||||
# Print python an pip version
|
||||
python -V && pip -V
|
||||
RUN pip install pyyaml
|
||||
RUN pip install ipython
|
||||
|
||||
##############################################################################
|
||||
# Some Packages
|
||||
##############################################################################
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libsndfile-dev \
|
||||
libcupti-dev \
|
||||
libjpeg-dev \
|
||||
libpng-dev \
|
||||
screen \
|
||||
libaio-dev
|
||||
RUN pip install psutil \
|
||||
yappi \
|
||||
cffi \
|
||||
ipdb \
|
||||
pandas \
|
||||
matplotlib \
|
||||
py3nvml \
|
||||
pyarrow \
|
||||
graphviz \
|
||||
astor \
|
||||
boto3 \
|
||||
tqdm \
|
||||
sentencepiece \
|
||||
msgpack \
|
||||
requests \
|
||||
pandas \
|
||||
sphinx \
|
||||
sphinx_rtd_theme \
|
||||
scipy \
|
||||
numpy \
|
||||
scikit-learn \
|
||||
nvidia-ml-py3 \
|
||||
mpi4py
|
||||
|
||||
##############################################################################
|
||||
## SSH daemon port inside container cannot conflict with host OS port
|
||||
###############################################################################
|
||||
ENV SSH_PORT=2222
|
||||
RUN cat /etc/ssh/sshd_config > ${STAGE_DIR}/sshd_config && \
|
||||
sed "0,/^Port 22/s//Port ${SSH_PORT}/" ${STAGE_DIR}/sshd_config > /etc/ssh/sshd_config
|
||||
|
||||
##############################################################################
|
||||
# PyTorch
|
||||
##############################################################################
|
||||
ENV PYTORCH_VERSION=1.13.0
|
||||
RUN pip install torch==${PYTORCH_VERSION}
|
||||
|
||||
##############################################################################
|
||||
# PyYAML build issue
|
||||
# https://stackoverflow.com/a/53926898
|
||||
##############################################################################
|
||||
RUN rm -rf /usr/lib/python3/dist-packages/yaml && \
|
||||
rm -rf /usr/lib/python3/dist-packages/PyYAML-*
|
||||
|
||||
##############################################################################
|
||||
## Add deepspeed user
|
||||
###############################################################################
|
||||
# Add a deepspeed user with user id 8877
|
||||
#RUN useradd --create-home --uid 8877 deepspeed
|
||||
RUN useradd --create-home --uid 1000 --shell /bin/bash deepspeed
|
||||
RUN usermod -aG sudo deepspeed
|
||||
RUN echo "deepspeed ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
# # Change to non-root privilege
|
||||
USER deepspeed
|
||||
|
||||
##############################################################################
|
||||
# DeepSpeed
|
||||
##############################################################################
|
||||
RUN git clone https://github.com/microsoft/DeepSpeed.git ${STAGE_DIR}/DeepSpeed
|
||||
RUN cd ${STAGE_DIR}/DeepSpeed && \
|
||||
git checkout . && \
|
||||
git checkout master && \
|
||||
./install.sh --pip_sudo
|
||||
RUN rm -rf ${STAGE_DIR}/DeepSpeed
|
||||
RUN python -c "import deepspeed; print(deepspeed.__version__)"
|
||||
68
finetune/peft-gpu-bnb-multi-source.Dockerfile
Normal file
68
finetune/peft-gpu-bnb-multi-source.Dockerfile
Normal file
@@ -0,0 +1,68 @@
|
||||
# Builds GPU docker image of PyTorch
|
||||
# Uses multi-staged approach to reduce size
|
||||
# Stage 1
|
||||
# Use base conda image to reduce time
|
||||
FROM continuumio/miniconda3:latest AS compile-image
|
||||
# Specify py version
|
||||
ENV PYTHON_VERSION=3.8
|
||||
# Install apt libs - copied from https://github.com/huggingface/accelerate/blob/main/docker/accelerate-gpu/Dockerfile
|
||||
RUN apt-get update && \
|
||||
apt-get install -y curl git wget software-properties-common git-lfs && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists*
|
||||
|
||||
# Install audio-related libraries
|
||||
RUN apt-get update && \
|
||||
apt install -y ffmpeg
|
||||
|
||||
RUN apt install -y libsndfile1-dev
|
||||
RUN git lfs install
|
||||
|
||||
# Create our conda env - copied from https://github.com/huggingface/accelerate/blob/main/docker/accelerate-gpu/Dockerfile
|
||||
RUN conda create --name peft python=${PYTHON_VERSION} ipython jupyter pip
|
||||
RUN python3 -m pip install --no-cache-dir --upgrade pip
|
||||
|
||||
# Below is copied from https://github.com/huggingface/accelerate/blob/main/docker/accelerate-gpu/Dockerfile
|
||||
# We don't install pytorch here yet since CUDA isn't available
|
||||
# instead we use the direct torch wheel
|
||||
ENV PATH /opt/conda/envs/peft/bin:$PATH
|
||||
# Activate our bash shell
|
||||
RUN chsh -s /bin/bash
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
# Stage 2
|
||||
FROM nvidia/cuda:12.1.0-devel-ubuntu22.04 AS build-image
|
||||
COPY --from=compile-image /opt/conda /opt/conda
|
||||
ENV PATH /opt/conda/bin:$PATH
|
||||
|
||||
RUN chsh -s /bin/bash
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
# Install apt libs
|
||||
RUN apt-get update && \
|
||||
apt-get install -y curl git wget cmake && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists*
|
||||
|
||||
# Activate the conda env and install transformers + accelerate from source
|
||||
# Also clone BNB and build it from source.
|
||||
RUN source activate peft && \
|
||||
python3 -m pip install -U --no-cache-dir \
|
||||
librosa \
|
||||
"soundfile>=0.12.1" \
|
||||
scipy \
|
||||
git+https://github.com/huggingface/transformers \
|
||||
git+https://github.com/huggingface/accelerate \
|
||||
peft[test]@git+https://github.com/huggingface/peft \
|
||||
optimum \
|
||||
auto-gptq && \
|
||||
git clone https://github.com/TimDettmers/bitsandbytes && cd bitsandbytes && git checkout multi-backend-refactor && \
|
||||
cmake -B . -DCOMPUTE_BACKEND=cuda -S . && \
|
||||
cmake --build . && \
|
||||
pip install -e . && \
|
||||
pip freeze | grep bitsandbytes
|
||||
|
||||
RUN echo "source activate peft" >> ~/.profile
|
||||
|
||||
# Activate the virtualenv
|
||||
CMD ["/bin/bash"]
|
||||
70
finetune/transformer.Dockerfile
Normal file
70
finetune/transformer.Dockerfile
Normal file
@@ -0,0 +1,70 @@
|
||||
FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04
|
||||
LABEL maintainer="Hugging Face"
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Use login shell to read variables from `~/.profile` (to pass dynamic created variables between RUN commands)
|
||||
SHELL ["sh", "-lc"]
|
||||
|
||||
# The following `ARG` are mainly used to specify the versions explicitly & directly in this docker file, and not meant
|
||||
# to be used as arguments for docker build (so far).
|
||||
|
||||
ARG PYTORCH='2.3.0'
|
||||
# (not always a valid torch version)
|
||||
ARG INTEL_TORCH_EXT='2.3.0'
|
||||
# Example: `cu102`, `cu113`, etc.
|
||||
ARG CUDA='cu121'
|
||||
|
||||
RUN apt update
|
||||
RUN apt install -y git libsndfile1-dev tesseract-ocr espeak-ng python3 python3-pip ffmpeg git-lfs
|
||||
RUN git lfs install
|
||||
RUN python3 -m pip install --no-cache-dir --upgrade pip
|
||||
|
||||
ARG REF=main
|
||||
RUN git clone https://github.com/huggingface/transformers && cd transformers && git checkout $REF
|
||||
|
||||
# 1. Put several commands in a single `RUN` to avoid image/layer exporting issue. Could be revised in the future.
|
||||
# 2. Regarding `torch` part, We might need to specify proper versions for `torchvision` and `torchaudio`.
|
||||
# Currently, let's not bother to specify their versions explicitly (so installed with their latest release versions).
|
||||
RUN python3 -m pip install --no-cache-dir -U tensorflow==2.13 protobuf==3.20.3 tensorflow_text tensorflow_probability && python3 -m pip install --no-cache-dir -e ./transformers[dev,onnxruntime] && [ ${#PYTORCH} -gt 0 -a "$PYTORCH" != "pre" ] && VERSION='torch=='$PYTORCH'.*' || VERSION='torch'; echo "export VERSION='$VERSION'" >> ~/.profile && echo torch=$VERSION && [ "$PYTORCH" != "pre" ] && python3 -m pip install --no-cache-dir -U $VERSION torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/$CUDA || python3 -m pip install --no-cache-dir -U --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/$CUDA
|
||||
|
||||
RUN python3 -m pip uninstall -y flax jax
|
||||
|
||||
RUN python3 -m pip install --no-cache-dir intel_extension_for_pytorch==$INTEL_TORCH_EXT -f https://developer.intel.com/ipex-whl-stable-cpu
|
||||
|
||||
RUN python3 -m pip install --no-cache-dir git+https://github.com/facebookresearch/detectron2.git pytesseract
|
||||
RUN python3 -m pip install -U "itsdangerous<2.1.0"
|
||||
|
||||
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/accelerate@main#egg=accelerate
|
||||
|
||||
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/peft@main#egg=peft
|
||||
|
||||
# For bettertransformer
|
||||
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/optimum@main#egg=optimum
|
||||
|
||||
# For video model testing
|
||||
RUN python3 -m pip install --no-cache-dir decord av==9.2.0
|
||||
|
||||
# Some slow tests require bnb
|
||||
RUN python3 -m pip install --no-cache-dir bitsandbytes
|
||||
|
||||
# Some tests require quanto
|
||||
RUN python3 -m pip install --no-cache-dir quanto
|
||||
|
||||
# `quanto` will install `ninja` which leads to many `CUDA error: an illegal memory access ...` in some model tests
|
||||
# (`deformable_detr`, `rwkv`, `mra`)
|
||||
RUN python3 -m pip uninstall -y ninja
|
||||
|
||||
# For `dinat` model
|
||||
# The `XXX` part in `torchXXX` needs to match `PYTORCH` (to some extent)
|
||||
RUN python3 -m pip install --no-cache-dir natten==0.15.1+torch220$CUDA -f https://shi-labs.com/natten/wheels
|
||||
|
||||
# For `nougat` tokenizer
|
||||
RUN python3 -m pip install --no-cache-dir python-Levenshtein
|
||||
|
||||
# For `FastSpeech2ConformerTokenizer` tokenizer
|
||||
RUN python3 -m pip install --no-cache-dir g2p-en
|
||||
|
||||
# When installing in editable mode, `transformers` is not recognized as a package.
|
||||
# this line must be added in order for python to be aware of transformers.
|
||||
RUN cd transformers && python3 setup.py develop
|
||||
Reference in New Issue
Block a user