| # 使用 TensorFlow 官方的 GPU 镜像,2.10.0-gpu | |
| FROM tensorflow/tensorflow:2.10.0-gpu | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # 替换为BFSU的镜像源并安装系统依赖 | |
| RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|https://mirrors.bfsu.edu.cn/ubuntu/|g' /etc/apt/sources.list && \ | |
| apt-get update -yy && \ | |
| apt-get install -yy --no-install-recommends ffmpeg libsm6 libxext6 && \ | |
| rm -rf /var/lib/apt/lists/* && \ | |
| apt-get clean | |
| # 设置pip使用BFSU的PyPI镜像源并安装Python库和DeepLabCut | |
| RUN pip config set global.index-url https://mirrors.bfsu.edu.cn/pypi/web/simple && \ | |
| pip install "deeplabcut[tf]" numpy==1.24.0 decorator==4.4.2 fastapi uvicorn && \ | |
| pip list | |
| # 修复 TensorFlow 与 protobuf 的兼容性问题 | |
| RUN pip install protobuf==3.20.1 | |
| # 修复容器权限问题,确保 DeepLabCut 可以正确运行 | |
| RUN chmod a+rwx -R /usr/local/lib/python3.*/dist-packages/deeplabcut/pose_estimation_tensorflow/models/pretrained | |
| # 复制 kunin-dlc-240814 目录到容器中 | |
| COPY kunin-dlc-240814 /app/kunin-dlc-240814 | |
| # 复制应用代码 | |
| COPY app.py /app/app.py | |
| # 设置工作目录 | |
| WORKDIR /app | |
| # 运行服务 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"] | |