Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@michaelharmonart

This comment has been minimized.

Copy link

@michaelharmonart michaelharmonart commented Feb 9, 2021

After installing and running everything when I run "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" it returns "docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]." Do you know what the problem might be?

@xenogenesi

This comment has been minimized.

Copy link
Owner Author

@xenogenesi xenogenesi commented Feb 9, 2021

Sorry I never seen that error, maybe a version problem? Are you using a docker-ce >= 19.03?

docker-ce                  5:20.10.3~3-0~debian-buster
docker-ce-cli              5:20.10.3~3-0~debian-buster
docker-ce-rootless-extras  5:20.10.3~3-0~debian-buster
@michaelharmonart

This comment has been minimized.

Copy link

@michaelharmonart michaelharmonart commented Feb 9, 2021

Yep when I run "docker version" it says I'm on docker community edition v 20.10.3

I'm on Ubuntu by the way (Well, actually Kubuntu, but it shouldn't make a difference)

@xenogenesi

This comment has been minimized.

Copy link
Owner Author

@xenogenesi xenogenesi commented Feb 9, 2021

It's been a few months since I tried it and it worked, in the meantime a few versions of the various nvidia components have been updated (I use debian/sid) and now I have some problems to make it work too, but it gives me a different error.

@michaelharmonart

This comment has been minimized.

Copy link

@michaelharmonart michaelharmonart commented Feb 9, 2021

Well, just due to time constraints I ended up installing it normally, without docker to do my tests. So there's no urgency for it to be fixed, but I wish you good luck!

@johde

This comment has been minimized.

Copy link

@johde johde commented May 6, 2021

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.

@iamkhalidbashir

This comment has been minimized.

Copy link

@iamkhalidbashir iamkhalidbashir commented Sep 11, 2021

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

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