Skip to content

Instantly share code, notes, and snippets.

@xenogenesi
Last active February 24, 2023 08:00
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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link

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
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?

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