Home > Blockchain >  Docker [Errno 13] Permission denied error when running with --u=$(id -u $USER):$(id -g $USER)
Docker [Errno 13] Permission denied error when running with --u=$(id -u $USER):$(id -g $USER)

Time:07-24

I try to run a docker container with a tkinter gui app in python and x11 forwarding for a machine learning application. When I run the image with

sudo docker run --runtime=nvidia --gpus='all' --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" -i ganspace

I got the following display connection error, but the app seams to run

Downloading https://drive.google.com/uc?export=download&id=1FJRwzAkV-XWbxgTwxEmEACvuqF5DsBiV
Not cached
[19.07 19:59] Computing stylegan2-ffhq_style_ipca_c80_n1000000_w.npz
Reusing InstrumentedModel instance
Using W latent space
Feature shape: torch.Size([1, 512])
B=10000, N=1000000, dims=512, N/dims=1953.1
Sampling latents: 100%|██████████| 101/101 [00:08<00:00, 11.80it/s]
Fitting batches (NB=10000): 100%|##########| 100/100 [00:19<00:00,  5.11it/s]Authorization required, but no authorization protocol specified
Authorization required, but no authorization protocol specified

Total time: 0:00:28.239383
Loaded components for ffhq from /ganspace/cache/components/stylegan2-ffhq_style_ipca_c80_n1000000_w.npz
Traceback (most recent call last):
  File "interactive.py", line 645, in <module>
    setup_ui()
  File "interactive.py", line 214, in setup_ui
    root = tk.Tk()
  File "/opt/conda/envs/ganspace/lib/python3.7/tkinter/__init__.py", line 2023, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":1"

If I run the image in the following way with

sudo docker run -u=$(id -u $USER):$(id -g $USER) -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw --rm -it --runtime=nvidia --gpus='all' ganspace

the display connection is working (I tested it with another tkinter image), but I got the following permission error due to the user I think

Traceback (most recent call last):
  File "interactive.py", line 644, in <module>
    setup_model()
  File "interactive.py", line 143, in setup_model
    inst = get_instrumented_model(model_name, class_name, layer_name, torch.device('cuda'), use_w=args.use_w)
  File "/opt/conda/envs/ganspace/lib/python3.7/functools.py", line 840, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/ganspace/models/wrappers.py", line 695, in get_instrumented_model
    model = get_model(name, output_class, device, **kwargs)
  File "/opt/conda/envs/ganspace/lib/python3.7/functools.py", line 840, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/ganspace/models/wrappers.py", line 680, in get_model
    model = StyleGAN2(device, class_name=output_class)
  File "/ganspace/models/wrappers.py", line 125, in __init__
    self.load_model()
  File "/ganspace/models/wrappers.py", line 160, in load_model
    os.makedirs(checkpoint.parent, exist_ok=True)
  File "/opt/conda/envs/ganspace/lib/python3.7/os.py", line 213, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/opt/conda/envs/ganspace/lib/python3.7/os.py", line 223, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/ganspace/models/checkpoints'
ERROR conda.cli.main_run:execute(49): `conda run python interactive.py --model=StyleGAN2 --class=ffhq --layer=style --use_w -n=1_000_000 -b=10_000` failed. (See above for error)

Any ideas how to fix this or another solution to have the right permission and get the connection to the display correctly? thanks in advance!

CodePudding user response:

It says permission issue because current user is not having the permission for

/ganspace/models/checkpoints directory

Add the below line in your Dockerfile to give permission for that path

 RUN chmod -R 777 /ganspace/models/checkpoints

Note: 777 gives full permission. change it accordingly based on what all permission you require. check permissions in linux

  • Related