我正在尝试设置huggingface空间。这是我的dockerfile
FROM python:3.9
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --prefer-binary -r /code/requirements.txt
RUN pip install --user matplotlib
COPY . .
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
当我尝试构建它并启动它时,它给了我以下错误:
-->
===== Application Startup =====
Fetching model from: https://huggingface.co/facebook/wav2vec2-large-960h-lv60-self
Traceback (most recent call last):
File "/usr/local/bin/uvicorn", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
......
File "/code/./app.py", line 3, in
gr.Interface.load("models/facebook/wav2vec2-large-960h-lv60-self").launch()
File "/usr/local/lib/python3.9/site-packages/gradio/interface.py", line 109, in load
return super().load(name=name, src=src, api_key=api_key, alias=alias, **kwargs)
File "/usr/local/lib/python3.9/site-packages/gradio/blocks.py", line 1154, in load
return external.load_blocks_from_repo(name, src, api_key, alias, **kwargs)
File "/usr/local/lib/python3.9/site-packages/gradio/external.py", line 58, in load_blocks_from_repo
blocks: gradio.Blocks = factory_methods[src](name, api_key, alias, **kwargs)
File "/usr/local/lib/python3.9/site-packages/gradio/external.py", line 311, in from_model
interface = gradio.Interface(**kwargs)
File "/usr/local/lib/python3.9/site-packages/gradio/interface.py", line 424, in __init__
self.flagging_callback.setup(
File "/usr/local/lib/python3.9/site-packages/gradio/flagging.py", line 187, in setup
os.makedirs(flagging_dir, exist_ok=True)
File "/usr/local/lib/python3.9/os.py", line 225, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: 'flagged'
我尝试通过添加RUN chown
语句来创建文件夹并授予权限,但似乎不起作用,我该如何解决这个问题?
1条答案
按热度按时间soat7uwm1#
发生了什么?
从哪里开始:
当我遇到这个问题时,我根据互联网上的建议尝试了一些事情,这些事情对我来说 * 不 * 工作,但对你来说可能是:
chmod -R 777 .
。Docker将在复制文件夹内容时复制这些文件的权限。完成解决方案:
以上两种方法本身对我都不起作用,但对我起作用的是:
1.将USER设置为root
1.相加
RUN chmod 777 ~/app/*
为了更好地实践,我还设置了一个非root用户,并在设置权限后切换回该用户。
下面是我的项目中使用的最后一个Dockerfile,它启动了一个运行在Debian Buster Linux映像上的gradio应用程序: