Installation Instructions (Docker) (Advanced) - skier233/nsfw_ai_model_server GitHub Wiki
Prerequisites
-
Ensure Docker (< v28.0) (If you want to use 28.0 or later, I can walk you through the process in discord) is installed on your system. You can download and install Docker from here.
-
For GPU support, ensure you have the NVIDIA Container Toolkit installed. Follow the steps below to install it:
-
Ubuntu:
sudo apt-get update sudo apt-get install -y nvidia-container-toolkit sudo systemctl restart docker
-
Windows:
Follow the instructions here to set up the GPU support for Windows.
-
Building the Docker Container
-
Navigate to the directory where you unzipped the release.
-
Build the Docker image using the following command:
docker build -t ai_model_server .
-
Start the docker container using the following command:
docker run --gpus all -p 8000:8000 -p 7483:7483 -v C:/Example/Media/Images/Folder:/media/images/folder:ro -v .\:/app ai_model_server
Modify the command and add in the paths to your media folders like the Example/Media path above. -
(If using a Patreon exclusive model) The first time you run the server, it'll try to authenticate with a browser and fail (since it can't start a browser in docker) and give you a link to download a license. Save the license file to your models folder and run the command in 3. again.
-
The server will expect paths in the format of the second value in the format of the second paths of the media mounts (
/media/images/folder
in the example above). If you send paths to the server that are paths from the host operating system it will not be able to see them. If you're using the official stash plugin, you can use the path_mutation value in the config.py file in the plugin directory to mutate paths from stash that are sent to the server. If stash is also running in a docker container then you can use the same paths for the target in step 3 as in the stash container and then mutation will not be needed. If stash is not running in a docker container then you'll want to add each path you defined above to the path_mutation dictionary like so:path_mutation = {"C:/Example/Media/Images/Folder": "/media/images/folder", "C:/Example/Media/Images/Folder2", "/media/images/folder2"}
Docker Updating Instructions
To update from a previous version run (windows) .\update.ps1
or (linux) source .\update.sh
.
Then, rebuild the docker container again using step 2 above.