requirements.txt文件中的CMAKE:安装适用于Mac的llama-cpp-python

iqjalb3h  于 6个月前  发布在  Python
关注(0)|答案(1)|浏览(66)

我已经将我的应用程序放入Docker中,因此我创建了一个requirements.txt文件。现在我需要安装Mac的llama-cpp-python,因为我正在从langchain.llms导入LlamaCpp加载我的LLM。
我的Mac安装命令是:
"CMAKE_ARGS="-DLLAMA_METAL=on" FORCE_CMAKE=1 pip install llama-cpp-python"
但是如果我把它放在我的“requirements.txt”文件中,它就不起作用了。
我的requirements.txt文件如下所示:

chromadb==0.4.14
langchain==0.0.354
pandas==2.0.3
python-dotenv==1.0.0
python_box==7.1.1
PyYAML==6.0.1
streamlit==1.29.0
torch==2.1.0
sentence-transformers==2.2.2
faiss-cpu==1.7.4
CMAKE_ARGS="-DLLAMA_METAL=on" FORCE_CMAKE=1 pip install llama-cpp-python # Does not work like this

字符串
在@ivvija的评论之后,我的Dockerfile看起来像这样:

FROM python:3.11.5
WORKDIR /app
COPY . .
RUN pip3 install -r requirements.txt
RUN CMAKE_ARGS="-DLLAMA_METAL=on" FORCE_CMAKE=1 pip install llama-cpp-python
EXPOSE 8501
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]


这会导致以下错误:ERROR: Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based projects
我该怎么做?

e7arh2l6

e7arh2l61#

我终于找到了一个解决方案:在你的Dockerfile中添加MAc的llama-cpp-python安装如下:

FROM python:3.11.5
WORKDIR /app
COPY . .
ENV RUN CMAKE_ARGS="-DLLAMA_METAL=on" FORCE_CMAKE=1
RUN pip install llama-cpp-python
RUN pip3 install -r requirements.txt
EXPOSE 8501
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]

字符串

相关问题