0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

EC2のインスタンスタイプを変更したらtensorflowコンテナが動かなくなった!

Posted at

経緯

もともとGPUを使用したEC2インスタンス(g4dn.xlarge)webアプリケーションを運用していました。
GPUインスタンスは料金が高いので、週末にはインスタンスを停止させていました。
ある月曜日に見てみると、Insufficient Instance Capacityというエラーが出て起動に失敗していました。
急いで復旧させる必要があったので、g6.xlargeというインスタンスにインスタンスを変更しました。
このとき、nvidia関係のドライバーなどをいれるためにいくつかOSやコマンドを打ちました。

本件

上記でwebアプリが起動することまで確認できて喜んでいたのですが、ユーザから、AI検出が動かないという連絡を受けました。

AIコンテナの見てみると下記のようでした。

| 1752818790160 | INFO:     Started server process [1]                                                                                                                                                                                                                      |
| 1752818790160 | INFO:     Waiting for application startup.                                                                                                                                                                                                                |
| 1752818790160 | INFO:     Application startup complete.                                                                                                                                                                                                                   |
| 1752818790161 | INFO:     Uvicorn running on http://0.0.0.0:8001 (Press CTRL+C to quit)                                                                                                                                                                                   |
| 1752818882793 | 2025-07-18 15:08:02.793521: I tensorflow/stream_executor/cuda/cuda_dnn.cc:369] Loaded cuDNN version 8100                                                                                                                                                  |
| 1752818883399 | 2025-07-18 15:08:03.399674: W tensorflow/stream_executor/gpu/asm_compiler.cc:231] Falling back to the CUDA driver for PTX compilation; ptxas does not support CC 8.9                                                                                      |
| 1752818883399 | 2025-07-18 15:08:03.399696: W tensorflow/stream_executor/gpu/asm_compiler.cc:234] Used ptxas at ptxas                                                                                                                                                     |
| 1752818883399 | 2025-07-18 15:08:03.399747: W tensorflow/stream_executor/gpu/redzone_allocator.cc:314] Unimplemented: ptxas ptxas too old. Falling back to the driver to compile.                                                                                         |
| 1752818883399 | Relying on driver to perform ptx compilation.                                                                                                                                                                                                             |
| 1752818883399 | Modify $PATH to customize ptxas location.                                                                                                                                                                                                                 |
| 1752818883399 | This message will be only logged once. 

特にエラーらしきものはなかったのですが、リクエスト元はこの時刻にコネクションロストしており、このログが怪しいと考えました。
このコンテナではGPUを使うつもりはなかったのにGPUを探していてエラーになっているようでした。

解決策

環境変数として、{ "name": "NVIDIA_VISIBLE_DEVICES", "value": "none" }を渡すと無事起動できました。

原因

おそらくnvidiaドライバをOSコマンドで入れた際に、新規のversionを入れてしまって、これまでGPUなしで動いていたコンテナがGPUを認識しようとして動かないという状態

そもそも

fargateを使ってサーバのことは忘れよう。
onnx変換をして推論はCPUで動くようにしよう。

学び

最初はリクエスト元が悪いと睨んでいた。ログをちゃんと読もう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?