Skip to content

Commit

Permalink
Merge pull request #931 from Capsize-Games/devastator
Browse files Browse the repository at this point in the history
build fixes for docker. remove xformers requirement
  • Loading branch information
w4ffl35 authored Oct 11, 2024
2 parents ff2bbe9 + 64f55a3 commit d282295
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 35 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.github
.idea
lib
dist
build
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ RUN cd qt-everywhere-src-6.7.0/build \
&& rm -rf qt-everywhere-src-6.7.0 qt-everywhere-src-6.7.0.tar.xz

FROM install_qt as create_user
ENV DEBIAN_FRONTEND=noninteractive
RUN useradd -ms /bin/bash appuser \
&& chown -R appuser:appuser /app \
&& apt-get update \
&& apt-get install -y libxkbcommon-x11-0 \
&& apt-get install -y nvidia-cudnn \
&& rm -rf /var/lib/apt/lists/*

USER appuser
Expand Down Expand Up @@ -142,13 +144,16 @@ RUN git clone https://github.com/Capsize-Games/airunner.git /app/airunner \
&& git pull \
&& python3 -m pip install build \
&& python3 -m build \
&& python3 -m pip install build dist/airunner-3.0.16-py3-none-any.whl
&& cd /app/airunner/dist \
&& WHL_FILE=$(ls airunner-*.whl) \
&& python3 -m pip install build $WHL_FILE

FROM build_airunner as build_airunner_executable
USER appuser
WORKDIR /app
ENV HOME=/app
ENV PATH="/home/appuser/.local/bin:${PATH}"
ENV PYTHONUSERBASE=/home/appuser/.local
COPY build.airunner.linux.prod.spec build.airunner.linux.prod.spec
RUN echo "test"
ENV DOCKER_ENV=true
COPY airunner.spec airunner.spec
COPY ./lib/tokenizers/punkt /app/lib/tokenizers/punkt
64 changes: 44 additions & 20 deletions airunner.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@
import site
import os

# Get the site-packages path
site_packages_path = site.getsitepackages()[0]
# Get the directory of the spec file
if os.getenv('DOCKER_ENV') == 'true':
root_path = os.path.dirname(os.path.abspath('airunner.spec'))
base_path = os.path.join(root_path, 'airunner')
site_packages_path = "/home/appuser/.local/lib/python3.10/site-packages/"
dist = "/app/dist"
else:
root_path = os.path.dirname(os.path.abspath('airunner.spec'))
base_path = root_path
site_packages_path = site.getsitepackages()[0]
dist = "./dist"

# Set the path to the airunner package
airunner_path = os.path.join(base_path, "src/airunner")

a = Analysis(
['./src/airunner/main.py'],
[os.path.join(airunner_path, 'main.py')],
pathex=[
'./src',
os.path.join(base_path, 'src'),
],
binaries=[
('/usr/lib/x86_64-linux-gnu/libpython3.10.so', '.'),
('./venv/lib/python3.10/site-packages/tiktoken/_tiktoken.cpython-310-x86_64-linux-gnu.so', '.'),
('/usr/lib/x86_64-linux-gnu/libcudnn.so.8', '.'), # Add libcudnn shared libraries
('/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8', '.'),
('/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8', '.'),
('/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8', '.'),
('/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8', '.'),
('/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8', '.'),
('/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8', '.'),
(os.path.join(site_packages_path, 'tiktoken/_tiktoken.cpython-310-x86_64-linux-gnu.so'), '.'),
(os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_adv.so.9'), '.'),
(os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_cnn.so.9'), '.'),
(os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_engines_precompiled.so.9'), '.'),
Expand All @@ -29,10 +33,17 @@ a = Analysis(
(os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_heuristic.so.9'), '.'),
(os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn_ops.so.9'), '.'),
(os.path.join(site_packages_path, 'nvidia/cudnn/lib/libcudnn.so.9'), '.'),

(os.path.join(site_packages_path, 'PySide6/Qt/lib/libQt6XcbQpa.so.6'), '.'),
(os.path.join(site_packages_path, 'PySide6/Qt/lib/libQt6DBus.so.6'), '.'),
(os.path.join(site_packages_path, 'PySide6/Qt/lib/libQt6Widgets.so.6'), '.'),
(os.path.join(site_packages_path, 'PySide6/Qt/lib/libQt6Gui.so.6'), '.'),
(os.path.join(site_packages_path, 'PySide6/Qt/lib/libQt6Core.so.6'), '.'),
('/usr/lib/x86_64-linux-gnu/libpython3.10.so', '.'),
('/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0', '.'),
('/usr/lib/x86_64-linux-gnu/libxkbcommon-x11.so.0.0.0', '.'),
],
datas=[
('./src/airunner/alembic.ini', '.'),
(os.path.join(airunner_path, 'alembic.ini'), '.'),
(os.path.join(site_packages_path, 'inflect'), 'inflect'),
(os.path.join(site_packages_path, 'controlnet_aux'), 'controlnet_aux'),
(os.path.join(site_packages_path, 'diffusers'), 'diffusers'),
Expand All @@ -42,6 +53,8 @@ a = Analysis(
(os.path.join(site_packages_path, 'xformers'), 'xformers'),
(os.path.join(site_packages_path, 'nvidia'), 'nvidia'),
(os.path.join(site_packages_path, 'llama_index'), 'llama_index'),
(os.path.join(site_packages_path, 'PySide6'), 'PySide6'),
(os.path.join(site_packages_path, 'PySide6/Qt/plugins/platforms'), 'platforms'),
# Add other data files or directories here
],
hiddenimports=[
Expand Down Expand Up @@ -83,6 +96,7 @@ a = Analysis(
'llama_index.core.chat_engine',
'llama_index.core.indices.keyword_table',
'llama_index.core.base.llms.types',
'PySide6',
],
hookspath=[],
hooksconfig={},
Expand Down Expand Up @@ -122,8 +136,18 @@ coll = COLLECT(
)

import shutil
shutil.copytree('./src/airunner/images/', './dist/airunner/_internal/airunner/images/')
shutil.copytree('./src/airunner/styles/', './dist/airunner/_internal/airunner/styles/')
shutil.copytree('./src/airunner/alembic/', './dist/airunner/_internal/alembic/')
shutil.copytree('./src/airunner/data/', './dist/airunner/data/')
shutil.copytree('./lib/tokenizers/punkt', './dist/airunner/_internal/llama_index/core/_static/nltk_cache/tokenizers/punkt')
images_path = os.path.join(airunner_path, 'images/')
styles_path = os.path.join(airunner_path, 'styles/')
alembic_path = os.path.join(airunner_path, 'alembic/')
data_path = os.path.join(airunner_path, 'data/')
punkt_path = os.path.join(root_path, 'lib/tokenizers/punkt/')
print(f"Copy images from {images_path}...")
shutil.copytree(images_path, os.path.join(base_path, os.path.join(dist, 'airunner/_internal/airunner/images/')))
print(f"Copy styles from {styles_path}...")
shutil.copytree(styles_path, os.path.join(base_path, os.path.join(dist, 'airunner/_internal/airunner/styles/')))
print(f"Copy alembic from {alembic_path}...")
shutil.copytree(alembic_path, os.path.join(base_path, os.path.join(dist, 'airunner/_internal/alembic/')))
print(f"Copy data from {data_path}...")
shutil.copytree(data_path, os.path.join(base_path, os.path.join(dist, 'airunner/data/')))
print(f"Copy punkt from {punkt_path}...")
shutil.copytree(punkt_path, os.path.join(base_path, os.path.join(dist, 'airunner/_internal/llama_index/core/_static/nltk_cache/tokenizers/punkt')))
6 changes: 1 addition & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
DISABLE_TELEMETRY=1
cd /app

# Ensure the build directory exists and set permissions
mkdir -p /app/build
chmod -R 777 /app/build

echo ""
echo "============================================"
echo "Installing dependencies"
Expand All @@ -18,7 +14,7 @@ echo "============================================"
echo "Build airunner for linux"
echo "============================================"
echo ""
DEV_ENV=0 AIRUNNER_ENVIRONMENT="prod" PYTHONOPTIMIZE=0 python3 -m PyInstaller --log-level=INFO --noconfirm /app/build.airunner.linux.prod.spec 2>&1 | tee build.log
DEV_ENV=0 AIRUNNER_ENVIRONMENT="prod" PYTHONOPTIMIZE=0 python3 -m PyInstaller --log-level=INFO --noconfirm /app/airunner.spec 2>&1 | tee build.log
echo ""
echo "============================================"
echo "Copy timm to dist"
Expand Down
11 changes: 7 additions & 4 deletions dobuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import json


# os.chdir("/app/airunner")
# os.system("git pull")
# os.system("python3 -m pip install .")

os.chdir("/app/airunner")
os.system("git pull")
os.system("python3 -m build")
os.system("cd dist")
os.system("WHL_FILE=$(ls airunner-*.whl)")
os.system("python3 -m pip install build $WHL_FILE")
os.system("python3 -m pip install .")
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="airunner",
version="3.0.17",
version="3.0.18",
author="Capsize LLC",
description="A Stable Diffusion GUI",
long_description=open("README.md", "r", encoding="utf-8").read(),
Expand All @@ -28,7 +28,6 @@
"optimum==1.21.4",
"numpy==1.26.4",
"pillow==10.4.0",
"xformers==0.0.28.post1",
"tensorflow==2.17.0",
"DeepCache==0.1.1",
"alembic==1.13.3",
Expand Down

0 comments on commit d282295

Please sign in to comment.