Skip to content

Instantly share code, notes, and snippets.

@xenogenesi
Last active December 13, 2023 14:44
Show Gist options
  • Save xenogenesi/e62d3d13dadbc164124c830e9c453668 to your computer and use it in GitHub Desktop.
Save xenogenesi/e62d3d13dadbc164124c830e9c453668 to your computer and use it in GitHub Desktop.
Docker file for Wav2Lip
# Ignore everything
**
# Allow files and directories
!/audio.py
!/Dockerfile
!/hparams.py
!/preprocess.py
!/checkpoints/
!/evaluation/
!/hq_wav2lip_train.py
!/README.md
!/temp/
!/color_syncnet_train.py
!/face_detection/
!/inference.py
!/requirements.txt
!/filelists/
!/models/
!/results/
!/wav2lip_train.py
# Ignore unnecessary files inside allowed directories
# This should go after the allowed directories
**/*~
**/*.log
**/.DS_Store
**/Thumbs.db
# 1. install a version of docker with gpu support (docker-ce >= 19.03)
# 2. enter the project directory and build the wav2lip image:
# docker build -t wav2lip .
# 3. allow root user to connect to the display
# xhost +local:root
# 4. instantiate the container
# docker run --rm --gpus all -v /tmp/.X11-unix:/tmp/.X11-unix -v $PWD:/workspace/src -e DISPLAY=$DISPLAY --device /dev/dri -ti wav2lip bash
# NOTES:
# export CUDA_VISIBLE_DEVICES="" ## force cpu only
# Based on https://github.com/1adrianb/face-alignment/blob/master/Dockerfile
FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
RUN export DEBIAN_FRONTEND=noninteractive RUNLEVEL=1 ; \
apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake git curl ca-certificates \
vim \
python3-pip python3-dev python3-wheel \
libglib2.0-0 libxrender1 python3-soundfile \
ffmpeg && \
rm -rf /var/lib/apt/lists/* && \
pip3 install --upgrade setuptools
# RUN curl -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
# chmod +x ~/miniconda.sh && \
# ~/miniconda.sh -b -p /opt/conda && \
# rm ~/miniconda.sh
# ENV PATH /opt/conda/bin:$PATH
# RUN conda config --set always_yes yes --set changeps1 no && conda update -q conda
# RUN conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
# # Install Wav2Lip package
# # NOTE we use the git clone to install the requirements only once
# # (if we use COPY it will invalidate the cache and reinstall the dependencies for every change in the sources)
WORKDIR /workspace
RUN chmod -R a+w /workspace
RUN git clone https://github.com/Rudrabha/Wav2Lip
WORKDIR /workspace/Wav2Lip
RUN pip3 install -r requirements.txt
RUN mkdir -p /root/.cache/torch/checkpoints && \
curl -SL -o /root/.cache/torch/checkpoints/s3fd-619a316812.pth "https://www.adrianbulat.com/downloads/python-fan/s3fd-619a316812.pth"
# !!! NOTE !!! nvidia-driver version must match the version installed on the host(/docker server)
RUN export DEBIAN_FRONTEND=noninteractive RUNLEVEL=1 ; \
apt-get update && apt-get install -y --no-install-recommends \
nvidia-driver-450 mesa-utils && \
rm -rf /var/lib/apt/lists/*
# create the working directory, to be mounted with the bind option
RUN mkdir /workspace/src
WORKDIR /workspace/src
@iamkhalidbashir
Copy link

I had to add RUN pip3 install --upgrade pip to the docker file just before RUN pip3 install -r requirements.txt to get it to install the requirements correctly.

This is important

@wangxingchao
Copy link

Exactly this works for me.

Why doesnot anyone had already created the docker image share to public repo?

@xenogenesi
Copy link
Author

Why doesnot anyone had already created the docker image share to public repo?

I haven't used this image for a while, lately when I need some python-ML projects I just use Conda.

@chrisbward
Copy link

I had to add RUN pip3 install --upgrade pip to the docker file just before RUN pip3 install -r requirements.txt to get it to install the requirements correctly.

This is important

Super important, was fun wasting time today

@Vipinstack
Copy link

Screenshot from 2023-02-24 13-29-06

image

" Do you know what the problem might be?

@Drake4537
Copy link

I have been having problems running with this error python: can't open file
'inference.py': [Errno 2] No such file or directory

@cabraljv
Copy link

The base image FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04 seems to be deprecated. Any pre-built image ready to run available?

@rudolfKischer
Copy link

The base image FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04 seems to be deprecated. Any pre-built image ready to run available?

Did any find a resolution for this?

I am having some issues trying to use newer base images

@dairydaddy
Copy link

Having issues with the regular conda dev too. Maybe some dependency stuff?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment