Merge pull request 'fix(worker): real image 加 tensorflow 支援 tflite' (#2) from fix/tflite-tensorflow into main
This commit is contained in:
commit
9dfd0e4d77
@ -50,8 +50,30 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
# 0.7.0 import 乾淨。
|
||||
# - onnxsim==0.4.36(--only-binary):py3.9/bullseye 上新版 onnxsim 無 wheel、需
|
||||
# cmake 從源碼編;0.4.36 有 prebuilt wheel,避免裝 build toolchain。
|
||||
# 4) numpy<2 最後裝:prebuild 鏈的 C-extension 以 numpy 1.x 編譯,numpy 2.x 會出
|
||||
# "numpy.core.multiarray failed to import"。最後安裝確保不被其他套件升級回 2.x。
|
||||
# 4) tflite 輸入格式轉檔(tflite→onnx,第一步 ktc.onnx_optimizer.tflite2onnx_flow)
|
||||
# 需要 tensorflow + python-igraph(converter: libs/ONNX_Convertor/tflite-onnx):
|
||||
# - tensorflow-cpu==2.13.1:挑此版的三重理由——
|
||||
# (a) Python 3.9 相容:2.13.x 支援 py3.8–3.11;再新的 TF(2.16+)drop py3.9。
|
||||
# (b) numpy<2 相容(最關鍵):TF 2.13.1 要求 numpy>=1.22,<=1.24.3(全 1.x),
|
||||
# 與既有 prebuild 鏈的「numpy 1.x」硬需求一致;再新的 TF(2.16+)會拉
|
||||
# numpy>=2 → 直接撞爆 prebuild 的 "numpy.core.multiarray failed to import"。
|
||||
# (c) ktc 需求:ktc/onnx_optimizer_1_13.py 的 _get_tensor_details_compat patch
|
||||
# 是為「較新 TF(tf.lite.Interpreter._get_tensor_details 需 subgraph_index,
|
||||
# TF 2.5+ 引入)」寫的 → TF 2.13.1 落在此範圍、patch 正常生效。
|
||||
# 選 -cpu 版:不需 GPU、省下 CUDA 相關 ~1.5GB。
|
||||
# - igraph==1.0.0:converter 的 tree_structure.py:13 `from igraph import Graph` 硬
|
||||
# import 需要(不裝→tflite→onnx 第一步 ModuleNotFoundError)。pin 死是為了
|
||||
# reproducible build——igraph 是 tflite 鏈的硬依賴、裸裝 latest 未來重 build 可能
|
||||
# 裝到行為改變的新版;1.0.0 是本次 build 實裝並驗證可跑的版本。
|
||||
# - typing-extensions>=4.8.0:TF 2.13.1 會把 typing-extensions 降到 4.5.0
|
||||
# (其 pin 是 <4.6),導致 fastapi 0.104.1 `import fastapi` 掛
|
||||
# `cannot import name 'TypeAliasType'`。TF 對 typing-extensions 的上限只是
|
||||
# *soft warning*(實測升到 4.15 後 tf 2.13.1 + tf.lite.Interpreter 仍正常),
|
||||
# 故在 TF 之後把 typing-extensions 補回 >=4.8.0,修復 fastapi/pydantic。
|
||||
# 5) numpy==1.23.5 最後裝並「釘死」:prebuild 鏈的 C-extension 以 numpy 1.x 編譯,
|
||||
# numpy 2.x 會出 "numpy.core.multiarray failed to import"。1.23.5 同時滿足
|
||||
# TF 2.13.1 的 numpy>=1.22,<=1.24.3 窗口 + 既有 prebuild/onnx 的 1.x 需求。
|
||||
# 最後安裝確保不被 TF/其他套件連帶升級。
|
||||
COPY services/workers/nef/requirements.txt /tmp/worker-requirements.txt
|
||||
RUN pip install --no-cache-dir \
|
||||
redis>=5.0 boto3>=1.28 \
|
||||
@ -63,7 +85,9 @@ RUN pip install --no-cache-dir \
|
||||
pyzipper dict_recursive_update beautifulsoup4 jinja2 matplotlib tabulate \
|
||||
commentjson IPython adjustText "onnx_tool==0.7.0" \
|
||||
&& pip install --no-cache-dir --only-binary :all: "onnxsim==0.4.36" \
|
||||
&& pip install --no-cache-dir "numpy<2"
|
||||
&& pip install --no-cache-dir "tensorflow-cpu==2.13.1" "igraph==1.0.0" \
|
||||
&& pip install --no-cache-dir "typing-extensions>=4.8.0" \
|
||||
&& pip install --no-cache-dir "numpy==1.23.5"
|
||||
|
||||
# --- Application + toolchain source ------------------------------------------
|
||||
# 精準 COPY,避免把 libs/dynasty(2.0G) + libs/compiler(1.2G) 帶進來。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user