Apache notes
parent
5dbe609b81
commit
e5319a9be3
330
src/WWW.tex
330
src/WWW.tex
|
@ -1,5 +1,5 @@
|
|||
%
|
||||
% StableDiffusion.tex
|
||||
% WWW.tex
|
||||
%
|
||||
% AI Documentation
|
||||
%
|
||||
|
@ -10,42 +10,15 @@
|
|||
%
|
||||
|
||||
\section{Introduction}
|
||||
Below is one of the many ways to set up a web proxy.
|
||||
It uses Apache, since that's what I've been using since the Usenet
|
||||
patch era, but others can be used like nginx.
|
||||
|
||||
Wiki:
|
||||
``Stable Diffusion is a deep learning, text-to-image model.
|
||||
It is primarily used to generate detailed images conditioned on text
|
||||
descriptions, though it can also be applied to other tasks such as
|
||||
inpainting, outpainting, and generating image-to-image
|
||||
translations guided by a text prompt.''
|
||||
|
||||
|
||||
* \url{https://stability.ai/stablediffusion}
|
||||
|
||||
* \url{https://en.wikipedia.org/wiki/Stable_Diffusion}
|
||||
|
||||
\begin{figure}[h!]
|
||||
\begin{framed}
|
||||
\centering
|
||||
\includegraphics[keepaspectratio=true,height=0.80\textheight,width=0.80\textwidth,angle=0]{stable-diffusion-www-1.png}
|
||||
\caption{Stable Diffusion website.}
|
||||
\label{fig:stable-diffusion-www-1}
|
||||
\end{framed}
|
||||
\end{figure}
|
||||
|
||||
|
||||
\section{Installation}
|
||||
Dump of install notes.
|
||||
|
||||
AUTOMATIC1111 and ComfyUI.
|
||||
Lots below isn't needed.
|
||||
This sets up SSL cert with a registered domain, which is need to be
|
||||
set up first. Example uses the domain ``ml0.deepcrayon.org''.
|
||||
|
||||
|
||||
\begin{minted}{sh}
|
||||
# Set up DNS
|
||||
|
||||
|
||||
# Set up apache
|
||||
```
|
||||
apt update
|
||||
apt install apache2 python3-certbot-apache
|
||||
a2enmod headers proxy proxy_http proxy_wstunnel rewrite ssl
|
||||
|
@ -53,14 +26,11 @@ a2ensite default-ssl 000-default
|
|||
echo `hostname` > /var/www/html/index.html
|
||||
systemctl restart apache2
|
||||
|
||||
# Open firewall ports 80/443 TCP.
|
||||
certbot -d v-ml11.deepcrayon.org
|
||||
certbot -d ml0.deepcrayon.org
|
||||
systemctl restart apache2
|
||||
|
||||
# https://v-ml11.deepcrayon.org/
|
||||
# ComfyUI example:
|
||||
|
||||
# Proxy config or comfyui:
|
||||
#vim /etc/apache2/sites-enabled/default-ssl.conf
|
||||
vim /etc/apache2/sites-available/comfyui.conf
|
||||
<VirtualHost *:443>
|
||||
ServerAdmin webmaster@localhost
|
||||
|
@ -80,14 +50,15 @@ vim /etc/apache2/sites-available/comfyui.conf
|
|||
<Location />
|
||||
ProxyPass http://127.0.0.1:8188/
|
||||
</Location>
|
||||
ServerName v-ml11.deepcrayon.org
|
||||
SSLCertificateFile /etc/letsencrypt/live/v-ml11.deepcrayon.org/fullchain.pem
|
||||
SSLCertificateKeyFile /etc/letsencrypt/live/v-ml11.deepcrayon.org/privkey.pem
|
||||
ServerName ml0.deepcrayon.org
|
||||
SSLCertificateFile /etc/letsencrypt/live/ml0.deepcrayon.org/fullchain.pem
|
||||
SSLCertificateKeyFile /etc/letsencrypt/live/ml0.deepcrayon.org/privkey.pem
|
||||
Include /etc/letsencrypt/options-ssl-apache.conf
|
||||
</VirtualHost>
|
||||
#
|
||||
|
||||
# Stable Diffusion WebUI Example:
|
||||
vim /etc/apache2/sites-available/sd-webui.conf
|
||||
#
|
||||
<VirtualHost *:443>
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /var/www/html
|
||||
|
@ -106,281 +77,22 @@ vim /etc/apache2/sites-available/sd-webui.conf
|
|||
<Location />
|
||||
ProxyPass http://127.0.1.1:7860/
|
||||
</Location>
|
||||
ServerName v-ml11.deepcrayon.org
|
||||
SSLCertificateFile /etc/letsencrypt/live/v-ml11.deepcrayon.org/fullchain.pem
|
||||
SSLCertificateKeyFile /etc/letsencrypt/live/v-ml11.deepcrayon.org/privkey.pem
|
||||
ServerName ml0.deepcrayon.org
|
||||
SSLCertificateFile /etc/letsencrypt/live/ml0.deepcrayon.org/fullchain.pem
|
||||
SSLCertificateKeyFile /etc/letsencrypt/live/ml0.deepcrayon.org/privkey.pem
|
||||
Include /etc/letsencrypt/options-ssl-apache.conf
|
||||
</VirtualHost>
|
||||
#
|
||||
|
||||
systemctl restart apache2
|
||||
|
||||
apt install libtcmalloc-minimal4 qemu-guest-agent aria2
|
||||
|
||||
# Set up for system with NV GPU
|
||||
git clone --recursive https://github.com/AUTOMATIC1111/stable-diffusion-webui
|
||||
cd stable-diffusion-webui
|
||||
# dev ?
|
||||
git checkout remotes/origin/dev
|
||||
git branch deepcrayon
|
||||
git checkout deepcrayon
|
||||
|
||||
pyenv install 3.10.6
|
||||
pyenv local 3.10.6
|
||||
virtualenv -ppython3.10.6 env
|
||||
source env/bin/activate
|
||||
pip install --upgrade pip
|
||||
pip install --upgrade setuptools wheel
|
||||
pip install lit
|
||||
|
||||
# NV CUDA 11.8
|
||||
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
|
||||
# for TORCH_USE_CUDA_DSA error ?
|
||||
# pip install numpy --pre torch torchvision torchaudio --force-reinstall --index-url https://download.pytorch.org/whl/nightly/cu117
|
||||
# pip install numpy -r requirements.txt --pre torch torchvision torchaudio --force-reinstall --index-url https://download.pytorch.org/whl/nightly/cu117
|
||||
# AMD GPU
|
||||
#pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.4.2
|
||||
|
||||
# Nightly NV CUDA 11.8 for -dev branch
|
||||
# pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu118
|
||||
# https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/8965
|
||||
# pip install numpy --pre torch torchvision torchaudio --force-reinstall --index-url https://download.pytorch.org/whl/nightly/cu118
|
||||
|
||||
pip install -r requirements_versions.txt
|
||||
|
||||
# ?
|
||||
pip install xformers
|
||||
# for nightly?
|
||||
pip install -v -U "git+https://github.com/facebookresearch/xformers.git@main#egg=xformers" torch==2.1.0.dev20230709+cu118
|
||||
|
||||
vim webui-user.sh
|
||||
# For ruinning with web proxy
|
||||
export COMMANDLINE_ARGS="--server-name=v-ml11.deepcrayon.org --no-gradio-queue --administrator --enable-insecure-extension-access"
|
||||
# For running on the LAN
|
||||
export COMMANDLINE_ARGS="--listen --no-gradio-queue --administrator --enable-insecure-extension-access"
|
||||
####################################################################
|
||||
####################################################################
|
||||
# webui-user.sh
|
||||
export COMMANDLINE_ARGS="--server-name=v-ml11.deepcrayon.org --no-gradio-queue --administrator --enable-insecure-extension-access"
|
||||
#export COMMANDLINE_ARGS="--server-name=v-ml11.deepcrayon.org --administrator --enable-insecure-extension-access"
|
||||
export SADTALKER_CHECKPOINTS=/home/jebba/devel/sadtalker/checkpoints
|
||||
####################################################################
|
||||
####################################################################
|
||||
|
||||
####################################################################
|
||||
# startup at boot
|
||||
# probably want syslog too ?
|
||||
apt install rsyslog
|
||||
|
||||
|
||||
# vim /home/jebba/bin/deepcrayon-comfyui-start
|
||||
|
||||
###################################################
|
||||
#!/bin/bash
|
||||
|
||||
# To disable Stable Diffusion example:
|
||||
sudo a2dissite sd-webui.conf
|
||||
|
||||
# To enable ComfyUI example:
|
||||
sudo a2ensite comfyui.conf
|
||||
|
||||
# Restart etc, after changes:
|
||||
systemctl reload apache2
|
||||
|
||||
cd /home/jebba/devel/comfyanonymous/ComfyUI
|
||||
|
||||
source env/bin/activate
|
||||
|
||||
python main.py
|
||||
###################################################
|
||||
cat > /etc/systemd/system/comfyui.service <<EOF
|
||||
[Unit]
|
||||
Description=comfyUI
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Environment="PYTHONUNBUFFERED=1"
|
||||
ExecStart=/home/jebba/bin/deepcrayon-comfyui-start
|
||||
WorkingDirectory=/home/jebba/devel/comfyanonymous/ComfyUI
|
||||
User=jebba
|
||||
Group=jebba
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
###################################################
|
||||
systemctl daemon-reload
|
||||
systemctl stop comfyui
|
||||
systemctl disable comfyui
|
||||
|
||||
|
||||
###################################################
|
||||
vim ~/bin/deepcrayon-sd-webui-start
|
||||
#
|
||||
###################################################
|
||||
#!/bin/bash
|
||||
|
||||
sudo a2dissite comfyui.conf
|
||||
sudo a2ensite sd-webui.conf
|
||||
systemctl reload apache2
|
||||
|
||||
cd /home/jebba/devel/AUTOMATIC1111/stable-diffusion-webui
|
||||
|
||||
source env/bin/activate
|
||||
|
||||
./webui.sh
|
||||
|
||||
###################################################
|
||||
#
|
||||
|
||||
chmod +x ~/bin/deepcrayon-sd-webui-start
|
||||
|
||||
sudo su -
|
||||
|
||||
###################################################
|
||||
cat > /etc/systemd/system/sd-webui.service <<EOF
|
||||
[Unit]
|
||||
Description=sd-webui
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Environment="PYTHONUNBUFFERED=1"
|
||||
ExecStart=/home/jebba/bin/deepcrayon-sd-webui-start
|
||||
WorkingDirectory=/home/jebba/devel/AUTOMATIC1111/stable-diffusion-webui
|
||||
User=jebba
|
||||
Group=jebba
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
###################################################
|
||||
#
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl disable sd-webui
|
||||
systemctl stop sd-webui
|
||||
###################################################
|
||||
# webui-user.sh
|
||||
export SADTALKER_CHECKPOINTS=/home/jebba/devel/sadtalker/checkpoints
|
||||
|
||||
# alternate
|
||||
sudo apt install espeak-ng espeak ffmpeg
|
||||
pip install tts
|
||||
###################################################
|
||||
###################################################
|
||||
(env) jebba@v-ml11:~/devel/AUTOMATIC1111/stable-diffusion-webui$
|
||||
cd ..
|
||||
git clone --recursive https://github.com/coqui-ai/TTS
|
||||
cd TTS/
|
||||
vim pyproject.toml
|
||||
# fix numpy version
|
||||
# ?
|
||||
pip install -r requirements.txt
|
||||
pip install -e .
|
||||
tts --help
|
||||
|
||||
###################################################
|
||||
###################################################
|
||||
###################################################
|
||||
(env) jebba@v-ml11:~/devel/AUTOMATIC1111/stable-diffusion-webui/extensions$ git clone --recursive https://github.com/OpenTalker/SadTalker.git
|
||||
cd SadTalker/
|
||||
git checkout remotes/origin/dev
|
||||
git branch deepcrayon
|
||||
git checkout deepcrayon
|
||||
###################################################
|
||||
###################################################
|
||||
###################################################
|
||||
# Nvidia nonfree shit XXX
|
||||
wget https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb
|
||||
sudo dpkg -i cuda-keyring_1.0-1_all.deb
|
||||
echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/ /" | sudo tee /etc/apt/sources.list.d/cuda-debian-x86_64.list
|
||||
|
||||
#wget https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-debian11.pin
|
||||
for i in `apt-cache search cuda|sort -V| grep cuda | grep 11-8 | grep -v -e cuda-demo-suite-11-8 -e cuda-documentation-11-8 -e cuda-gdb-11-8 -e cuda-gdb-src-11-8 | cut -f 1 -d " " ` ; do echo $i ; apt install $i ; echo ;done
|
||||
|
||||
###################################################
|
||||
# build pytorch
|
||||
# need non-free to install intel-mkl
|
||||
apt install libzstd-dev libnuma-dev clang gcc-11 libfftw3-dev libopenblas64-dev libopenblas-dev libblis-dev libblis64-dev libclblast-dev libxnnpack-dev libopenblas-openmp-dev libopenblas64-openmp-dev libopenmpi-dev libcudnn8-dev intel-mkl-full nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
|
||||
sudo apt install `apt-cache search opencv|grep -i opencv |sort -V|grep dev |cut -f 1 -d " "`
|
||||
libmagma-dev libarmnn-dev libonnx-dev
|
||||
sudo apt install `apt-cache search lapack|grep -- -dev | cut -f 1 -d " " | grep -v ghc`
|
||||
libmimalloc-dev
|
||||
sudo apt install `apt-cache search vulkan | grep -- -dev | grep -i vulkan | cut -f 1 -d " "`
|
||||
glslc libshaderc-dev
|
||||
libideep-dev
|
||||
|
||||
# using virtualenv from sd web
|
||||
git clone pytorch
|
||||
cd pytorch
|
||||
git checkout XXX
|
||||
git submodule sync
|
||||
git submodule update --init --recursive
|
||||
|
||||
export CMAKE_CUDA_ARCHITECTURES=native
|
||||
export CPUINFO_BUILD_TOOLS=1
|
||||
export BUILD_BINARY=1
|
||||
export TORCH_USE_CUDA_DSA=1
|
||||
export USE_CUDA=1
|
||||
export USE_OPENCV=1
|
||||
export USE_FFMPEG=1
|
||||
export USE_ZSTD=1
|
||||
-DCMAKE_CUDA_COMPILER:PATH=/usr/local/cuda/bin/nvcc
|
||||
#python setup.py develop
|
||||
mkdir build
|
||||
cd build/
|
||||
cmake ..
|
||||
ccmake ..
|
||||
###################################################
|
||||
###################################################
|
||||
|
||||
|
||||
sudo update-alternatives --remove-all gcc
|
||||
sudo update-alternatives --remove-all g++
|
||||
|
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 10
|
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 20
|
||||
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 10
|
||||
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 20
|
||||
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
|
||||
sudo update-alternatives --set cc /usr/bin/gcc
|
||||
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
|
||||
sudo update-alternatives --set c++ /usr/bin/g++
|
||||
|
||||
sudo update-alternatives --config gcc
|
||||
sudo update-alternatives --config g++
|
||||
|
||||
pip install mkl-devel
|
||||
|
||||
sudo apt remove --purge --autoremove libcu++-dev
|
||||
sudo apt install nvidia-cuda-dev
|
||||
libleveldb-dev
|
||||
|
||||
# ok
|
||||
# rm -rf build ; CUDACXX=/usr/local/cuda/bin/nvcc GCC="/usr/bin/gcc-11" CMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc python setup.py build
|
||||
# Test
|
||||
#rm -rf build ; CUDACXX=/usr/local/cuda/bin/nvcc CMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc python setup.py build
|
||||
cd .. ; rm -rf build ; mkdir build ; cd build/ ; \
|
||||
cmake -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -DENABLE_CUDA=ON -DUSE_CUDA=ON -DUSE_CUDNN=ON -DUSE_NVRTC=ON -DUSE_OPENCV=ON -DUSE_ZSTD=ON -DUSA_MKL=ON -DBUILD_CAFFE2=ON .. ; \
|
||||
make -j12
|
||||
ccmake -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -DENABLE_CUDA=ON -DUSE_CUDA=ON -DUSE_CUDNN=ON -DUSE_NVRTC=ON -DUSE_OPENCV=ON -DUSE_ZSTD=ON -DUSE_MKL=ON -DBUILD_CAFFE2=ON ..
|
||||
|
||||
# ? -Wno-dev
|
||||
# /home/jebba/devel/pytorch/pytorch/aten/src/ATen/native/quantized/cpu/qconv_prepack.cpp:412:73: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
|
||||
|
||||
|
||||
# nope
|
||||
sudo apt purge libideep-dev
|
||||
-DBUILD_CAFFE2=ON
|
||||
-DUSE_VULKAN=ON
|
||||
-DBUILD_BINARY=ON
|
||||
-DUSE_OPENCL=ON
|
||||
-DUSE_FFMPEG=ON
|
||||
|
||||
Manually-specified variables were not used by the project:
|
||||
|
||||
USA_MKL
|
||||
|
||||
# XXX where?
|
||||
TORCH_USE_CUDA_DSA
|
||||
\end{minted}
|
||||
|
||||
|
|
Loading…
Reference in New Issue