Install and test Automatic1111 Stable Diffusion
Install Python3.10 and it’s virtual env package.
|
|
The Deadsnakes PPA is a Personal Package Archive maintained by a group of volunteers that provides newer Python versions (and sometimes older versions that are no longer included in Ubuntu’s official repositories). IT’s well-maintained and trusted by the community
Find the automatic1111’s stable diffusion webui github repo and clone it to ai fodler. Hey this repo seems not for cpu only.
|
|
Run it for the first time, downloading the default models
|
|
Create a SSH tunnel and access the web console through http://localhost:7860
|
|
moving the application to mnt volume with bigger space
mv ai /mnt/mydisk/
and hope it will work as is. However, the python venv has a lot of hardcoded path in scripts and even binary files.
Eventually I have to remove the a1111env folder and recreate a venv again. However, I have saved some time by manually moved some big models folders etc. nvidia/tensor before pip install again.
Using the webui.sh
Is there a better way to start the stable-diffusion by activate the venv and launch.py with all those parameters? Is there a way to access the site without using port forward? Let’s using the repo’s default webui starting script webui.sh.
It does the python vevn stuff, I believe it will even create one if there isn’t one already created.
However it doesn’t work for me by default - of course I need to custmize for all those parameters, right? When I study the script, I realized that they want me to modify webui-user.sh for customization.
|
|
I studied the webui-user.sh, found it’s meant to set some variables to customize the behavior of webui.sh. After quite a few tests, I found the following changes need to be made:
|
|
Here are some explainations:
- the “–listen” is to fix the problem that webui listen to 127.0.0.1 only.
在服务器上运行以下命令查看 Web UI 是否监听 0.0.0.0:
sudo netstat -tuln | grep 7860
如果看到以下输出,说明 Web UI 已开放给所有网络设备:tcp 0 0 0.0.0.0:7860 0.0.0.0:* LISTEN
如果只看到 127.0.0.1:7860,说明只监听了本地,你需要加上 –listen 参数重新启动。 在 Stable Diffusion Web UI(Automatic1111 版) 的源码中(launch.py),–listen 参数的作用已经明确地将监听地址绑定为 0.0.0.0。这是 –listen 的默认行为。如果你使用 python3 launch.py –listen, 服务将对本地和外部网络都可访问。 - “–use-cpu all –no-half –skip-torch-cuda-test –enable-insecure-extension-access” is from the command above to start the webui
- “a1111venv” is from the error prompt when running webui.sh. If I don’t change this, it will try to create a venv on the fly.
After the above changes, webui.sh will start webui and listen to access from the world.
Create the systemd service file
To make it a server, we need to start stable-diffusion-webui automatically.
|
|