stable-diffusion-webui-docker icon indicating copy to clipboard operation
stable-diffusion-webui-docker copied to clipboard

Permission denied

Open qingyuan0o0 opened this issue 1 year ago • 8 comments

`docker run -it --name sdw --network host -v $(pwd)/models:/app/stable-diffusion-webui/models -v $(pwd)/outputs:/app/stable-diffusion-webui/outputs --rm siutin/stable-diffusion-webui-docker:latest-cpu bash webui.sh --skip-torch-cuda-test --use-cpu all --share

################################################################ Install script for stable-diffusion + Web UI Tested on Debian 11 (Bullseye) ################################################################

################################################################ Running on app user ################################################################

################################################################ Repo already cloned, using it as install directory ################################################################

################################################################ Create and activate python venv ################################################################

################################################################ Launching launch.py... ################################################################ Using TCMalloc: libtcmalloc_minimal.so.4 Python 3.10.12 (main, Jul 5 2023, 18:54:27) [GCC 11.2.0] Version: v1.5.1 Commit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a Launching Web UI with arguments: --skip-torch-cuda-test --use-cpu all --share no module 'xformers'. Processing without... no module 'xformers'. Processing without... No module 'xformers'. Proceeding without it. Traceback (most recent call last): File "/app/stable-diffusion-webui/launch.py", line 39, in main() File "/app/stable-diffusion-webui/launch.py", line 35, in main start() File "/app/stable-diffusion-webui/modules/launch_utils.py", line 390, in start import webui File "/app/stable-diffusion-webui/webui.py", line 54, in from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, queue_lock # noqa: F401 File "/app/stable-diffusion-webui/modules/call_queue.py", line 6, in from modules import shared, progress, errors File "/app/stable-diffusion-webui/modules/shared.py", line 83, in os.makedirs(cmd_opts.hypernetwork_dir, exist_ok=True) File "/app/miniconda3/lib/python3.10/os.py", line 225, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/app/stable-diffusion-webui/models/hypernetworks' `

qingyuan0o0 avatar Aug 18 '23 18:08 qingyuan0o0

I am getting the same thing currently using docker compose:

services:
  stable-diffusion:
    image: siutin/stable-diffusion-webui-docker:latest-cuda
    command: bash webui.sh --share
    ports:
      - 7861:7860
    volumes:
      - ./models:/app/stable-diffusion-webui/models
      - ./outputs:/app/stable-diffusion-webui/outputs
    deploy:
      resources:
        reservations:
          devices:
          - driver: nvidia
            count: all
            capabilities: [ gpu ]

Josh-XT avatar Aug 19 '23 13:08 Josh-XT

This could be resolved with the following commands:

mkdir -p /MY-DATA-DIR && cd /MY-DATA-DIR
mkdir models outputs
sudo chown 10000:$UID -R models outputs
sudo chmod 775 -R models outputs

siutin avatar Aug 19 '23 15:08 siutin

This could be resolved with the following commands:

mkdir -p /MY-DATA-DIR && cd /MY-DATA-DIR
mkdir models outputs
sudo chown 10000:$UID -R models outputs
sudo chmod 775 -R models outputs

Could that be added to the dockerfile?

Josh-XT avatar Aug 19 '23 22:08 Josh-XT

Excellent, I tested successfully. Thank you very much!

qingyuan0o0 avatar Aug 21 '23 03:08 qingyuan0o0

In case this comes up for you, The solution proposed here (and re-stated in the documentation) didn't work for me on Arch Linux. I'm not sure why, however, what did work was:

podman unshare chown -R 10000:10000 models outputs

This is when running the container in rootless mode. Just wanted to comment this here in case anybody else has this problem.

mvstrawn avatar Jan 19 '24 00:01 mvstrawn

My guess is that the source code has the wrong path.

Wrong path '/app/stable-diffusion-webui/models/hypernetworks'

Correct path '/app/stable-diffusion-webui/modules/hypernetworks'

everdt-MaShuai avatar Mar 12 '24 05:03 everdt-MaShuai

Please consider making the UID and GID configurable with environment variables. This essentially forces the end user to have to create a specific user account with that exact UID/GID if they want to interact with those files outside of a1111. It also prevents the user from being able to to share SD files between different interfaces if other docker instances have a different user IDs.

Another option would be to use the default ID of 1000 instead of 10000.

computercam avatar Jun 21 '24 14:06 computercam

agreed PGID and PUID at 1000, configurable in env varibles. The thought of doing this manually on each node in my swarm in nauseating.

shandshellin avatar Aug 24 '24 19:08 shandshellin