Deep-Live-Cam icon indicating copy to clipboard operation
Deep-Live-Cam copied to clipboard

Failed to build insightface ERROR: Could not build wheels for insightface, which is required to install pyproject.toml-based projects

Open tontheonelove opened this issue 1 year ago • 15 comments

i see error

Failed to build insightface ERROR: Could not build wheels for insightface, which is required to install pyproject.toml-based projects

tontheonelove avatar Aug 08 '24 08:08 tontheonelove

I had the same issue on my desktop where I was building a project on Windows 10.

You need to install Microsoft build tools from this link (or latest) https://aka.ms/vs/17/release/vs_BuildTools.exe Select: Workloads → Desktop development with C++ Individual Components must be checked:

Windows SDK C++ x64/x86 build tools C++ CMake tools for Windows

dungrk avatar Aug 09 '24 09:08 dungrk

and on Mac?

jasonkneen avatar Aug 10 '24 08:08 jasonkneen

@jasonkneen install Nix, create shell.nix in the repo, and run nix-shell, it'll just work:

{ pkgs ? import <nixpkgs> {} }:

let
  pythonWithTk = pkgs.python310.buildEnv.override {
    extraLibs = with pkgs.python310Packages; [ 
      tkinter
      pip
      virtualenv
    ];
    ignoreCollisions = true;
  };
in
pkgs.mkShell {
  buildInputs = with pkgs; [
    pythonWithTk
    clang
    llvmPackages.libcxx
    cmake
    pkg-config
    ffmpeg
    git
    tcl
    tk
  ];

  shellHook = ''
    export VENV_DIR="$PWD/.venv"
    if [ ! -d "$VENV_DIR" ]; then
      ${pythonWithTk}/bin/python -m venv $VENV_DIR
      source $VENV_DIR/bin/activate
      pip install --upgrade pip setuptools wheel
    else
      source $VENV_DIR/bin/activate
    fi

    export PYTHONPATH="${pythonWithTk}/lib/python3.10/site-packages:$PYTHONPATH"
    export TCL_LIBRARY="${pkgs.tcl}/lib/tcl${pkgs.tcl.version}"
    export TK_LIBRARY="${pkgs.tk}/lib/tk${pkgs.tk.version}"

    pip install --upgrade "onnxruntime-silicon==1.13.1"

    if [ -f requirements.txt ]; then
      pip install -r requirements.txt --upgrade
    fi

    python --version
  '';
}

andreivolt avatar Aug 10 '24 18:08 andreivolt

Thanks -- nix looks cool -- have been using Conda -- it was going REALLY well but got an error

      running build_ext
      building 'insightface.thirdparty.face3d.mesh.cython.mesh_core_cython' extension
      creating build/temp.macosx-11.0-arm64-cpython-310
      creating build/temp.macosx-11.0-arm64-cpython-310/insightface
      creating build/temp.macosx-11.0-arm64-cpython-310/insightface/thirdparty
      creating build/temp.macosx-11.0-arm64-cpython-310/insightface/thirdparty/face3d
      creating build/temp.macosx-11.0-arm64-cpython-310/insightface/thirdparty/face3d/mesh
      creating build/temp.macosx-11.0-arm64-cpython-310/insightface/thirdparty/face3d/mesh/cython
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/nix/store/y4jnf1smcbpw5sb2pnj1yih65jqbak7z-libxcrypt-4.4.36/include -Iinsightface/thirdparty/face3d/mesh/cython -I/usr/local/opt/portaudio/include/ -I/Users/jkneen/Documents/GitHub/Deep-Live-Cam/.venv/include -I/nix/store/ayd8dlnzbgpmi3d60rby6bg39bq5ai2d-python3-3.10.14/include/python3.10 -c insightface/thirdparty/face3d/mesh/cython/mesh_core.cpp -o build/temp.macosx-11.0-arm64-cpython-310/insightface/thirdparty/face3d/mesh/cython/mesh_core.o
      In file included from insightface/thirdparty/face3d/mesh/cython/mesh_core.cpp:11:
      insightface/thirdparty/face3d/mesh/cython/mesh_core.h:5:10: fatal error: 'cmath' file not found
      #include <cmath>
               ^~~~~~~
      1 error generated.
      error: command '/nix/store/wsgvg07q93xmaqp6ln58kzr75rg6jm40-clang-wrapper-16.0.6/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for insightface
Failed to build insightface
ERROR: Could not build wheels for insightface, which is required to install pyproject.toml-based projects
Python 3.10.14
(.venv)
[nix-shell:~/Documents/GitHub/Deep-Live-Cam]$```

Reinstalling command line tools

jasonkneen avatar Aug 11 '24 10:08 jasonkneen

strange, I was getting this error before I went the Nix route, I can't repro

try setting these before running nix-shell, supposing you have the Xcode CLI tools installed:

export CPLUS_INCLUDE_PATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1:$CPLUS_INCLUDE_PATH"
export LIBRARY_PATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib:$LIBRARY_PATH"
export CXXFLAGS="-stdlib=libc++ -std=c++14"
export LDFLAGS="-stdlib=libc++"

if it works add it to shell.nix

that said, the UI starts up and is functional, but I couldn't get it to work with the "live" option, haven't tried a file

andreivolt avatar Aug 11 '24 10:08 andreivolt

oooh, first one I didn't have (explains a lot recently) and now I've added that I get lumpy errors instead so that's "good" lol

      insightface/thirdparty/face3d/mesh/cython/mesh_core_cython.cpp:1259:10: fatal error: 'numpy/arrayobject.h' file not found
      #include "numpy/arrayobject.h"
               ^~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      error: command '/nix/store/wsgvg07q93xmaqp6ln58kzr75rg6jm40-clang-wrapper-16.0.6/bin/clang' failed with exit code 1
      [end of output]```

jasonkneen avatar Aug 11 '24 10:08 jasonkneen

try adding numpy to the packages array at the top, although it should be handled by the venv

andreivolt avatar Aug 11 '24 10:08 andreivolt

Got it working somehow but framerate is shocking even on M3 Silicon with 128gb RAM

jasonkneen avatar Aug 12 '24 22:08 jasonkneen

I couldn't get it to work, sometimes the preview window appears sometimes not, camera turns on, but no image.

If it's so slow maybe it's not using GPU for some reason.

andreivolt avatar Aug 13 '24 11:08 andreivolt

Yeh sorted all that -- it's using GPU and CPU currently as CPU usage went from 600% to 150% and trying to get rid of that completely, plus speed up the RGB conversion etc

jasonkneen avatar Aug 13 '24 11:08 jasonkneen

Me as Pedro Pascal Screenshot 2024-08-13 at 12 23 47

Screenshot 2024-08-13 at 12 24 07

jasonkneen avatar Aug 13 '24 11:08 jasonkneen

Cool, what did you do?

andreivolt avatar Aug 13 '24 11:08 andreivolt

Here's a recording -- actual frame rate I got so far

https://www.dropbox.com/t/GZNaukv55K96QuZy

Added a load of logging then basic got the code reworked with some "help" to get coreML working.

I haven't tested a fresh install but let me know and will put up a fork so we can colab on it

jasonkneen avatar Aug 13 '24 11:08 jasonkneen

Putting it up shortly, just finalising it

jasonkneen avatar Aug 13 '24 12:08 jasonkneen

Here you go, contributions appreciated -- just tweaking still

https://github.com/jasonkneen/Deep-Live-Cam.git

jasonkneen avatar Aug 13 '24 12:08 jasonkneen