camel-oasis (transitively via sentence-transformers) hard-imports torch in
oasis/social_platform/recsys.py, so torch cannot be removed while OASIS
simulation is a feature. On linux-x86_64 the default PyPI torch wheel is the
CUDA build, which dragged ~several GB of nvidia-* packages into the image
even though this server has no GPU and all LLM + embedding calls go through
an API (generate_post_vector_openai).
Fix: force torch to resolve from PyTorch's CPU-only index via [tool.uv]:
- override-dependencies torch==2.13.0, [[tool.uv.index]] pytorch-cpu, and
[tool.uv.sources] torch={index=pytorch-cpu}.
Result after re-lock: all nvidia-* + triton packages removed (0 remaining in
uv.lock), torch 2.9.1 -> 2.13.0+cpu. Verified: torch/sentence_transformers/
oasis/from app import create_app all import fine with CPU torch
(cuda: False); backend suite 201 passed. Dockerfile keeps an import-time
verify after uv sync instead of the now-unneeded nvidia uninstall step.
73 lines
1.7 KiB
TOML
73 lines
1.7 KiB
TOML
[project]
|
|
name = "crowdsight-backend"
|
|
version = "0.1.0"
|
|
description = "CrowdSight - 简洁通用的群体智能引擎,预测万物"
|
|
requires-python = ">=3.11,<3.13"
|
|
license = { text = "AGPL-3.0" }
|
|
authors = [
|
|
{ name = "CrowdSight Team" }
|
|
]
|
|
|
|
dependencies = [
|
|
# 核心框架
|
|
"flask>=3.0.0",
|
|
"flask-cors>=6.0.0",
|
|
# LLM 相关
|
|
"openai>=1.0.0",
|
|
# Zep Cloud
|
|
"zep-cloud==3.13.0",
|
|
# OASIS 社交媒体模拟
|
|
"camel-oasis==0.2.5",
|
|
"camel-ai==0.2.78",
|
|
# 文件处理
|
|
"PyMuPDF>=1.24.0",
|
|
# 编码检测(支持非UTF-8编码的文本文件)
|
|
"charset-normalizer>=3.0.0",
|
|
"chardet>=5.0.0",
|
|
# 工具库
|
|
"python-dotenv>=1.0.0",
|
|
"pydantic>=2.0.0",
|
|
"sqlalchemy>=2.0,<3",
|
|
"gunicorn>=21.2.0",
|
|
"alembic>=1.13,<2",
|
|
"argon2-cffi>=23.1",
|
|
"psycopg[binary]>=3.2",
|
|
"cryptography>=41.0",
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
dev = [
|
|
"pytest>=8.0.0",
|
|
"pytest-asyncio>=0.23.0",
|
|
"pipreqs>=0.5.0",
|
|
]
|
|
|
|
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[dependency-groups]
|
|
dev = [
|
|
"pytest>=8.0.0",
|
|
"pytest-asyncio>=0.23.0",
|
|
]
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
packages = ["app"]
|
|
|
|
# Force torch (transitively pulled by camel-oasis -> sentence-transformers) to
|
|
# resolve from PyTorch's CPU-only index. The server has no GPU and all LLM and
|
|
# embedding calls go through an API, so the CUDA build (which drags several GB
|
|
# of nvidia-* packages) is pure waste. torch keeps working as a CPU runtime;
|
|
# recsys.py's `import torch` / `import sentence_transformers` still succeed.
|
|
[tool.uv]
|
|
override-dependencies = ["torch==2.13.0"]
|
|
|
|
[[tool.uv.index]]
|
|
name = "pytorch-cpu"
|
|
url = "https://download.pytorch.org/whl/cpu"
|
|
explicit = true
|
|
|
|
[tool.uv.sources]
|
|
torch = { index = "pytorch-cpu" }
|