Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NixOS compatibility (via nix-shell) #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be tested and rebased, but Ok for that.
Very nice work by the way ! :)

Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
- Fedora 39
- OpenSUSE Leap 15.5
- OpenSUSE Tumbleweed
- NixOS (via nix-shell)
- Windows 10 22H2
- Windows 11 22H2
- macOS ???
Expand Down Expand Up @@ -206,6 +207,29 @@ sh <(curl https://raw.githubusercontent.com/Woolverine94/biniou/main/oci-rhel.sh
sh <(curl https://raw.githubusercontent.com/Woolverine94/biniou/main/oci-debian.sh || wget -O - https://raw.githubusercontent.com/Woolverine94/biniou/main/oci-debian.sh)
```

#### NixOS (via nix-shell)

```sh
# Open a port through the firewall to allow temporary (until next boot) remote access for containers and other services
open-port() {
if [ -z "$1" ]; then
echo "Usage: open-port <port>"
return 1
fi
local port=$1
sudo iptables -A INPUT -p tcp --dport $port -j ACCEPT
sudo systemctl reload firewall
}

git clone https://github.com/Woolverine94/biniou
cd biniou
nix-shell
./install.sh
# open-port 7860 # uncomment to open NixOS firewall port if accessing from a remote machine
(sleep 3; xdg-open https://0.0.0.0:7860) &
./webui.sh
```

##### Manual installation :

1. **Install** the pre-requisites as root :
Expand Down
9 changes: 5 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
ENV_PYTHON_TEST="$ENV_BINIOU_PYTHON_VER"
if [ "$ENV_PYTHON_TEST" != "" ]
then
Expand All @@ -12,17 +12,18 @@ mkdir -p ./ssl
mkdir -p ./models/Audiocraft

## Creating self-signed certificate
openssl req -x509 -newkey rsa:4096 -keyout ./ssl/key.pem -out ./ssl/cert.pem -sha256 -days 3650 -nodes -subj "/C=FR/ST=Paris/L=Paris/O=Biniou/OU=/CN="
[ ! -e ./ssl/key.pem ] && openssl req -x509 -newkey rsa:4096 -keyout ./ssl/key.pem -out ./ssl/cert.pem -sha256 -days 3650 -nodes -subj "/C=FR/ST=Paris/L=Paris/O=Biniou/OU=/CN="
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not seeing it before : don't do that. There's zero reasons for this certificate to exist, as this is script is not handling at all an existing installation.


## Creating virtual environment
eval $PYTHON_VER -m venv ./env
source ./env/bin/activate

## Install packages :
set -e # stop if any command below fails
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do that : warnings in the installation of some components sometimes gives useful hints for debugging. Blame is on my installer, that should handle correctly failures.

pip install -U pip
pip install wheel
pip install torch==2.1.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
FORCE_CMAKE=1 pip install llama-cpp-python
pip install -r requirements.txt
FORCE_CMAKE=1 pip install llama-cpp-python
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See following comment.

# pip install torch==2.1.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely don't do that !
Installation order is important. I don't want it to be changed.
Also, torch==2.1.0 is mandatory and should be forced. Don't comment it, please.

If all the changes you made in install.sh (except for the shebang) have a real interest for NixOS, please provide a specific install_nix.sh and update documentation.


exit 0
37 changes: 37 additions & 0 deletions shell.nix
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be tested, but Ok for that.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
buildInputs = with pkgs; [
stdenv.cc.cc.lib
python311
openssl
perl
ffmpeg
gperftools
libGL
libGLU
glib
xorg.libX11
xorg.libXi
xorg.libXmu
xorg.libXext
xorg.libXt
xorg.libXfixes
xorg.libXrender
xorg.libXcursor
xorg.libxcb
xorg.libXinerama
xorg.libXrandr
xorg.libXcomposite
];

shellHook = ''
export LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [
pkgs.libGL
pkgs.libGLU
pkgs.xorg.libX11
pkgs.glib
]}:$LD_LIBRARY_PATH
'';
}
2 changes: 1 addition & 1 deletion update.sh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be tested, but Ok for that.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
if [ -f ".ini/llamacpp_backend.cfg" ]
then
LLAMACPP_ARGS="$(cat .ini/llamacpp_backend.cfg)"
Expand Down
2 changes: 1 addition & 1 deletion update_cuda.sh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be tested, but Ok for that.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usrbin/env bash
if [ -f ".ini/llamacpp_backend.cfg" ]
then
LLAMACPP_ARGS="$(cat .ini/llamacpp_backend.cfg)"
Expand Down
2 changes: 1 addition & 1 deletion update_rocm.sh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be tested, but Ok for that.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
if [ -f ".ini/llamacpp_backend.cfg" ]
then
LLAMACPP_ARGS="$(cat .ini/llamacpp_backend.cfg)"
Expand Down
2 changes: 1 addition & 1 deletion webui.sh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be tested, but Ok for that.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
## Detection of TCMalloc
RELEASE="$(cat /etc/os-release|grep ^ID)"

Expand Down