iperov / DeepFaceLive

Real-time face swap for PC streaming or video calls
GNU General Public License v3.0
26.03k stars 4.43k forks source link

docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]. #67

Closed jiapei100 closed 2 years ago

jiapei100 commented 2 years ago

Hi, I'm testing this great job under Ubuntu 22.04... However, I got the following ERROR message:

➜  linux git:(master) sudo ./start.sh -c /dev/video0

Starting with camera devices
--device=/dev/video0:/dev/video0 --device=/dev/video1:/dev/video1

Sending build context to Docker daemon  6.656kB
Step 1/13 : FROM nvidia/cuda:11.4.2-cudnn8-runtime-ubuntu20.04
 ---> ecc3321906a4
Step 2/13 : WORKDIR /app
 ---> Using cache
 ---> beb4e81b6791
Step 3/13 : ARG DEBIAN_FRONTEND=noninteractive
 ---> Using cache
 ---> 53588afd1f86
Step 4/13 : RUN apt update
 ---> Using cache
 ---> 9e1188cc8f98
Step 5/13 : RUN apt -y install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 curl ffmpeg git nano gnupg2 libsm6 wget unzip libxcb-icccm4 libxkbcommon-x11-0 libxcb-keysyms1 libxcb-icccm4 libxcb-render0 libxcb-render-util0 libxcb-image0
 ---> Using cache
 ---> 68a62de47be4
Step 6/13 : RUN apt install -y python3 python3-pip
 ---> Using cache
 ---> 1499c55a57f7
Step 7/13 : RUN ln -s /usr/bin/python3 /usr/bin/python
 ---> Using cache
 ---> dfd8ed228c2e
Step 8/13 : RUN git clone https://github.com/iperov/DeepFaceLive.git
 ---> Using cache
 ---> 15d19c1747ad
Step 9/13 : RUN python -m pip install --upgrade pip
 ---> Using cache
 ---> a6a6a4055d24
Step 10/13 : RUN python -m pip install onnxruntime-gpu==1.11.1 numpy==1.21.6 h5py numexpr protobuf==3.20.1 opencv-python==4.5.5.64 opencv-contrib-python==4.5.5.64 pyqt6==6.3.0 onnx==1.11.0 torch==1.10.0 torchvision==0.11.1
 ---> Using cache
 ---> 9590a2814123
Step 11/13 : WORKDIR /app/DeepFaceLive
 ---> Using cache
 ---> 3e8d1646b08d
Step 12/13 : COPY example.sh example.sh
 ---> Using cache
 ---> 25dc41dc4edb
Step 13/13 : CMD ./example.sh
 ---> Using cache
 ---> ddbac6f781c0
Successfully built ddbac6f781c0
Successfully tagged deepfacelive:latest
access control disabled, clients can connect from any host
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
➜  linux git:(master) 
iperov commented 2 years ago

@CeeBeeEh any ideas?

CeeBeeEh commented 2 years ago

could not select device driver "" with capabilities: [[gpu]].

You're missing something on your host, maybe the GPU drivers aren't properly installed.

What's your output of nvidia-smi?

VisionaryMind commented 2 years ago

You are going to see this error message for any Ubuntu NVIDIA drivers above 470. Apparently, this code was built on 470 and does not handle the device calls for the higher driver versions. I have 20.04 LTS with nvidia-driver-510 and DeepFaceLive does not recognize it. I'm not willing to downgrade driver versions just to use this tool. Hopefully, the author will handle it soon.

iperov commented 2 years ago

the author will handle it soon.

linux is only supported by contributors such as CeeBeeEh.

iperov commented 2 years ago

@VisionaryMind

this code was built on 470

show me the code

VisionaryMind commented 2 years ago

show me the code

It's the Docker image (I believe). It was built on nvidia-driver-470. @CeeBeeEh, I have tried to resolve the issue by installing the nvidia-container-toolkit and restarting Docker, but the issue persists. I'll continue to troubleshoot and post updates here.

VisionaryMind commented 2 years ago

@jiapei100, I have found a workaround for this problem (if your GPU is NVIDIA). I jumped to the wrong conclusion about NVIDIA driver incompatibility. The problem is, in fact, in Docker itself. Here is what I did to fix the problem:

  1. Uninstall Docker completely by removing all the packages with sudo snap remove --purge docker
  2. Check if any packages are lingering -- dpkg -l | grep -i docker
  3. Purge the system, if necessary, with sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli and sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce
  4. Manually remove the docker folders and other related files -- sudo rm -rf /var/lib/docker /etc/docker sudo rm /etc/apparmor.d/docker and sudo groupdel docker and sudo rm -rf /var/run/docker.sock
  5. Re-install docker with curl https://get.docker.com | sh && sudo systemctl --now enable docker
  6. Set the distrubition variable:
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
      && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
      && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
            sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
            sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
  1. Now install the nvidia-container-runtime:
sudo apt-get update
sudo apt-get install -y nvidia-docker2
  1. Restart the Docker daemon to complete the installation after setting the default runtime:

sudo systemctl restart docker

I would first try steps 6-8, in case your Docker installation is valid (mine was not). Now, I am able to run the DeepFaceLive docker image on Ubuntu 20.04 LTS with nvidia-driver-510, no problem.

Hope this helps you.

CeeBeeEh commented 2 years ago

I just tested DeepFaceLive on a fresh Arch install (I just did a clean install of EndeavorOS) with Nvidia driver 515.48.07. The only additional thing I needed to install (outside of the the docker and nvidia-container-runtime) was xorg-xhost.

Aside from that it works just fine.

Unless @jiapei100 provides feedback (such as the output of nvidia-smi) there's not much anyone can do.

@VisionaryMind Nvidia had rotated its keys a couple months ago. That may have been the cause of the issue on your system.

Here is the announcement: https://forums.developer.nvidia.com/t/notice-cuda-linux-repository-key-rotation/212772