Docker构建huggingface transfer-learning-conv-ai镜像模块缺失报错
conv-ai项目Docker构建报错解决方案
报错原因
- 未指定
spacy版本,拉取的最新版spacy 3.0.5编译时依赖numpy、Cython等编译工具,基础镜像未预装这类包 - 原配置的依赖未锁定版本,存在兼容性问题
修复操作
1. 更新requirements.txt
替换为以下锁定版本的依赖列表:
torch==1.8.0 pytorch-ignite==0.4.4 transformers==2.5.1 tensorboardX==1.8 tensorflow==1.14.0 spacy==2.2.4 numpy==1.19.5 Cython==0.29.24 setuptools==58.0.0 wheel==0.37.0
2. 更新Dockerfile
补充系统编译依赖,调整pip安装流程:
FROM ubuntu:18.04 MAINTAINER Loreto Parisi loretoparisi@gmail.com ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y apt-utils RUN apt-get install -y --no-install-recommends \ build-essential \ pkg-config \ tzdata \ curl \ gcc \ g++ \ python3-dev RUN apt-get install -y \ python3 \ python3-pip RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \ dpkg-reconfigure --frontend noninteractive tzdata RUN pip3 install --upgrade pip==21.3.1 ENV PYTHONPATH /usr/local/lib/python3.6 COPY . ./ COPY requirements.txt /tmp/requirements.txt RUN pip3 install -r /tmp/requirements.txt RUN python3 -m spacy download en RUN mkdir models && \ curl -o models/finetuned_chatbot_gpt.tar.gz https://s3.amazonaws.com/models.huggingface.co/transfer-learning-chatbot/finetuned_chatbot_gpt.tar.gz && \ cd models/ && \ tar -xvzf finetuned_chatbot_gpt.tar.gz && \ rm finetuned_chatbot_gpt.tar.gz CMD ["bash"]
3. 执行重新构建命令
docker build -t convai . --no-cache
注:
--no-cache参数跳过旧的缓存层,避免复用之前出错的构建中间文件。
若依赖下载速度过慢,可在pip安装命令中添加国内镜像源参数加速。
若构建过程中出现内存不足报错,可适当调高Docker分配的内存上限。
内容的提问来源于stack exchange,提问作者moon
相关产品推荐
相关产品推荐

