Porting/chaiNNer

From RCS Wiki
Jump to navigation Jump to search

Installation on Debian Bookworm

  • Install at least one of PyTorch, ONNX, or ncnn
  • Install Electron
  • Pin Debian's python3 so that Electron will use Debian's PyTorch package (See Bedrock pinning instructions)
  • sudo brl apply
  • Download and extract a portable zip Linux x86_64 binary of chaiNNer.
  • Rename chainner executable in chaiNNer directory to chainner.bak (this is an Electron executable; we will replace it with the ppc64le Electron that we installed).
  • Rename portable file in chaiNNer directory to portable.bak (skip this step if you want chaiNNer configuration to be stored in chaiNNer's directory instead of $HOME).
  • In chaiNNer's directory, create the following shell script named chainner:
#!/usr/bin/env bash

cd "$(dirname "$0")"
electron ./resources/app "$@" --no-sandbox
  • Give the chainner script executable permissions, and (if you like) add the chaiNNer directory to your PATH.
  • Run chaiNNer once. It will produce an error dialog "Unable to install integrated Python" and ask you what to do. Choose "Use System Python instead". ChaiNNer will launch but the GUI will appear to hang. Exit chaiNNer.
  • Run the following commands to take care of some remaining dependencies:
mkdir -p ~/.config/chaiNNer/settings/
echo true > ~/.config/chaiNNer/settings/use-system-python
mkdir -p ~/.config/chaiNNer/ffmpeg/
ln -s -T /bedrock/cross/bin/ffprobe ~/.config/chaiNNer/ffmpeg/ffprobe
ln -s -T /bedrock/cross/bin/ffmpeg ~/.config/chaiNNer/ffmpeg/ffmpeg
# https://github.com/chaiNNer-org/chaiNNer/blob/main/backend/src/dependencies/install_server_deps.py
# https://github.com/chaiNNer-org/chaiNNer/blob/main/backend/src/packages/chaiNNer_standard/__init__.py
# https://github.com/chaiNNer-org/chaiNNer/blob/main/backend/src/packages/chaiNNer_pytorch/__init__.py
# Debian Forky doesn't package python3-numba for ppc64el.
# PyPI numba depends on llvmlite; Debian Forky packages python3-llvmlite 0.44.0.
# The numba version that supports llvmlite 0.44.0 is 0.61.2.
# If you want non-free Spandrel architectues, also install spandrel_extra_arches
sudo apt install python3-requests python3-wcmatch libre2-dev python3-aiofiles python3-websockets python3-typing-extensions python3-psutil python3-aiohttp python3-numpy python3-opencv python3-pil python3-scipy libavif-dev python3-llvmlite python3-einops python3-safetensors
pip install --user --break-system-packages sanic Sanic-Cors ffmpeg-python google-re2 html5tagger sanic-routing tracerite pillow-avif-plugin numba==0.61.2 PyMatting chainner_ext spandrel
# facexlib depends on a redistribution of OpenCV; we use Debian's python3-opencv instead, so we need to patch facexlib's requirements.txt
git clone https://github.com/xinntao/facexlib.git
pushd facexlib
nano requirements.txt
# Comment out opencv-python
nano setup.py
# Replace return locals()['__version__'] with return '0.3.0' due to PEP 667 compat bug in facexlib
pip install --user --break-system-packages .
popd
# Navigate to chaiNNer binary dir
pip install --user --break-system-packages ./resources/src/dependencies/whls/chainner-pip/chainner_pip*.whl
  • chaiNNer is installed!

Finished

Merged, Awaiting Stable Tag

(None at the moment.)

In Progress

See Also