ollama version is 0.12.5

ubuntu 24.04 64bit

问题:设置OLLAMA_MODELS=/home/username/ollama/models后,ollama服务无法启动,查看日志:ollama[779068]: Error: mkdir /home/username/ollama: permission denied: ensure path elements are traversable

说是权限问题,但是通过sudo chown +R 修改目录所有者为ollama,还是无效。后来在github上看到:https://github.com/ollama/ollama/issues/2147

The issue, as also described in the post, is that ollama tries to create the entire directory structure which you specify in the OLLAMA_MODELS environment variable. So even if you do a chown -R ollama:ollama /my/path/model_dir ollama tries to do a mkdir /my/path and errors out. The solution in the forum post is do a bind mount:

sudo mount --bind /my/path/model_dir /usr/share/ollama/.ollama/models

大概意思是ollama会创建整个目录结构。

后来我直接把/etc/systemd/system/ollama.service.d/override.conf里的用户名和组都改成自己用户名,再重启服务就可以了。

Logo

中国智能体开发者社区,聚焦智能体与大模型开发,提供前沿资讯、实用工具链、开源项目及行业案例。通过技术沙龙、开发者大赛等活动,促进经验交流与协作,助力开发者快速构建创新智能应用。

更多推荐