VisualGLM-6B
VisualGLM-6B copied to clipboard
运行web_demo_hf.py时遇到tmp文件写入被拒的问题
跑cli_demo_hf.py命令行界面运行良好,但运行web版本时发现,提交任何文本都不会响应,后经过摸索发现,gradio模块的访问临时文件被服务器拒绝,请问有什么解决方案
gradio 的文件映射由 tempfile._TemporaryFileWrapper 实现, 请在shell中尝试:
> python
import tempfile
tempfile.gettempdir()
预期输出为
/tmp/
你可以选择在代码中加入:
tempfile.tempdir = "./tmp"
来临时将 tempfile 制定到项目根目录,或者其他你有权限的位置
非常棒,你的办法有效,感谢你的解答
tempfile.tempdir = "./tmp"
你好,我用了你说的方法,但是一直报FileNotFoundError,创建了文件夹后又报新的: FileNotFoundError [Errno 2] No such file or directory: './tmp/tmpg4o6naoc'
tempfile.tempdir = "./tmp"
你好,我用了你说的方法,但是一直报FileNotFoundError,创建了文件夹后又报新的: FileNotFoundError [Errno 2] No such file or directory: './tmp/tmpg4o6naoc'
from transformers import AutoModel, AutoTokenizer
import gradio as gr
import mdtex2html
import tempfile
import os
os.makedirs("./tmp", exist_ok=True)
tempfile.tempdir = "./tmp"
tokenizer = AutoTokenizer.from_pretrained("model/chatglm-6b", trust_remote_code=True)
model = AutoModel.from_pretrained("model/chatglm-6b", trust_remote_code=True).half().cuda()
model = model.eval()
这样试试呢