2026年3月現在、Google Colabで tflite-model-maker をインストールしようとしても、エラーで動きません。
昔のTensorFlow Lite Model Makerチュートリアルをそのまま動かしたい人にとっては、なかなか困る状況です。
この記事は、
とにかく昔のTensorFlow Lite Model Makerのチュートリアルをそのまま動かしたい!
という方向けの回避策メモです。
🎯 対象読者
-
tflite-model-makerを使ったNotebookを動かしたい人 - 昔のTensorFlow Liteチュートリアルを再現したい人
- Colabでエラーにハマった人
❌ Colabで発生するエラー
Colabで以下を実行すると…
!pip install -q tflite-model-maker
次のエラーが出ます。
Installing build dependencies ... done
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
どうやら Colab側のTensorFlowバージョンとの整合性問題 で、ビルドに失敗しているようです。
🐳 解決策:Dockerで環境を固定する
Colabがダメなら、環境を固定してしまえばいい。
ということで、DockerでJupyter Notebook環境を構築しました。
📝 Dockerfile
FROM python:3.8
RUN apt-get update && apt-get install -y \
build-essential \
protobuf-compiler \
git \
libusb-1.0-0 libgl1 libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip
RUN pip install numpy==1.23.3
RUN pip install tensorflow==2.8.0
RUN pip install tflite-model-maker==0.4.3
RUN pip install notebook
RUN pip install pycocotools
WORKDIR /workspace
EXPOSE 8888
CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--allow-root", "--no-browser"]
🏗 イメージ作成 & 起動
docker build -t tflite-maker-env .
docker run -it --rm -p 8888:8888 -v "$($pwd.Path)\content:/workspace" tflite-maker-env
これでローカルにNotebook環境が立ち上がります。
📚 実行するチュートリアル
以下の公式チュートリアルを実行しました。
TensorFlow Lite Model Maker による画像分類
https://www.tensorflow.org/lite/tutorials/model_maker_image_classification
⚠ 実行時に出る警告たち
import時にいくつか警告が出ます。
結論から言うと、チュートリアルを進める分には問題ありませんでした(たぶん)。
① libcudart.so.11.0 が無い
Could not load dynamic library 'libcudart.so.11.0'
Ignore above cudart dlerror if you do not have a GPU set up
👉 GPUが無効なだけです。CPU環境なら無視してOK。
② Python 3.8 が古いぞ警告
You are using Python 3.8 past its end of life.
tflite-model-makerを動かすためには、仕方なしです。
③ TensorFlow Addons 終了のお知らせ
TensorFlow Addons has ended development
これは公式に開発終了しています。
④ TensorFlow Addons と TensorFlow のバージョン不一致
Tensorflow Addons supports TF >=2.11 and <2.14
You are using TensorFlow 2.8.0 and is not supported
これはversionを変えた方がいいのかな...
ただし今回は TensorFlow 2.8.0 のままでもチュートリアルは完走できました。
💥 トレーニング中のメモリ警告
学習中にこんな警告が出ました。
Allocation of 19267584 exceeds 10% of free system memory.
意味はざっくり言うと:
約19MB確保しようとしてるけど、それ空きメモリの10%以上だよ?
即クラッシュ系ではありません。
🛠 解決方法ランキング
🥇 1位:バッチサイズを下げる
batch_size=32 → 16 → 8
🥈 2位:画像サイズを小さく
224x224 → 160x160 → 128x128
🥉 3位:ランタイムをリセット
ランタイム → セッションを再起動
メモリ断片化がリセットされます。
🧪 4位:今のメモリ使用量を見る
!free -h
RAM使用量をチェックできます。
✅ まとめ
- 2026年3月現在、Colabでは
tflite-model-makerはほぼ動かない - DockerでPython 3.8 + TensorFlow 2.8.0 環境を固定すると動く
- 警告は多いが、チュートリアルは完走可能
- メモリ警告はバッチサイズで対処できる