[英]Docker [Errno 13] Permission denied error when running with --u=$(id -u $USER):$(id -g $USER)
I try to run a docker container with a tkinter gui app in python and x11 forwarding for a machine learning application.我尝试在 python 中运行带有 tkinter gui 应用程序的 docker 容器,并为机器学习应用程序运行 x11 转发。 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显示连接正在工作(我用另一个 tkinter 图像对其进行了测试),但是由于我认为的用户,我得到了以下权限错误
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!提前致谢!
It says permission issue because current user is not having the permission for它说权限问题,因为当前用户没有权限
/ganspace/models/checkpoints
directory /ganspace/models/checkpoints
目录
Add the below line in your Dockerfile to give permission for that path在 Dockerfile 中添加以下行以授予该路径的权限
RUN chmod -R 777 /ganspace/models/checkpoints
Note: 777 gives full permission.注意: 777 给予完全许可。 change it accordingly based on what all permission you require.根据您需要的所有权限进行相应更改。 check permissions in linux检查linux中的权限
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.