3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

大規模言語モデルのパラメーター数ごとに適したSageMakerインスタンスタイプはこれだ!価格感もあるよ

Last updated at Posted at 2023-09-03

大規模言語モデル利用を想定すると、GPUメモリの量が重要ですが、一体パラメーター数ごとにどれくらいのインスタンスタイプが必要なのか、実際に調べてみました!

判断基準は以下の通り。トークン数などの制限などは考慮しておらず、とりあえず動くかどうかの確認のみです。

  • 起動すること
  • 簡単なプロンプトを与えて答えが返ってくること

検証したモデル

日本語対応の大規模言語モデルもたくさん出てきました! ありがとうございます!!

パラメーター数3B未満

パラメーター数3B

パラメーター数7B

パラメーター数10B

コンテナタイプ

HuggingFace Inference Container

Hugging FaceのモデルをAmazon SageMakerに簡単にデプロイできるコンテナイメージ。2021年7月に公開。

HuggingFace Text Generation Inference Container

特に大規模言語モデルに特化したコンテナイメージ。2023年6月に公開。

検証方法

まずはSageMakerにデプロイし、エンドポイントが正常に起動するかを確認しました。正常に起動した場合は以下のプロンプトを投げ、返事が返ってきたらOKとしました。返事の内容までは気にしていません。

プロンプト
My name is Clara and I am

小さいサイズのインスタンスから順に繰り返し、正常動作が確認できた場合はそのモデルに対する検証は終了、正常に動作しなかった場合はインスタンスタイプを一つあげ、再度実行しました。

SageMakerの推論エンドポイントへのデプロイ方法はこちらを参照ください。

検証結果

モデル パラメーター数 インスタンス コンテナタイプ 備考
line-corporation/japanese-large-lm-1.7b-instruction-sft 1.7B ml.g4dn.2xlarge HuggingFace Inference Container
line-corporation/japanese-large-lm-3.6b-instruction-sft 3.6B ml.g4dn.2xlarge HuggingFace Inference Container
rinna/japanese-gpt-neox-3.6b-instruction-ppo 3.6B ml.g4dn.2xlarge HuggingFace Inference Container
cyberagent/open-calm-3b 3B ml.g4dn.2xlarge HuggingFace Inference Container
elyza/ELYZA-japanese-Llama-2-7b-fast-instruct 7B ml.g4dn.12xlarge HuggingFace Text Generation Inference Container
stabilityai/StableBeluga-7B 7B ml.g4dn.12xlarge HuggingFace Text Generation Inference Container
matsuo-lab/weblab-10b-instruction-sft 10B ml.g5.12xlarge HuggingFace Text Generation Inference Container SM_NUM_GPUS="2"
stabilityai/StableBeluga-13B 13B ml.g5.12xlarge HuggingFace Text Generation Inference Container

パラメーター数が70Bのmeta-llama/Llama-2-70b-chat-hfstabilityai/StableBeluga2も試したのですが、ml.g5.48xlargeを使ってもうまくいきませんでした。今後も継続して検証したいと思います。

2023/09/04追記:

HF_MODEL_QUANTIZEというオプションにbitsandbytesを指定することでメモリ使用量を抑えることができるとのことです。

このオプションを指定することで、パラメーター数7Bのelyza/ELYZA-japanese-Llama-2-7b-fast-instructをml.g5.2xlarge(GPU数:1)で起動させることに成功しました。

SageMaker価格

価格順でソートしてます。

インスタンスタイプ
vCPU / メモリ
GPU
モデル
GPU
容量 x 数量 = 合計
バージニア
価格(1h)
バージニア
価格(720h)
ml.g4dn.xlarge
4vCPU / 16GB
T4 16GB x 1 = 16GB $0.7364 $530.208
ml.g4dn.2xlarge
8vCPU / 32GB
T4 16GB x 1 = 16GB $0.94 $676.8
ml.g5.xlarge
4vCPU / 16GB
A10G 24GB x 1 = 24GB $1.41 $1,015.2
ml.g4dn.4xlarge
16vCPU / 64GB
T4 16GB x 1 = 16GB $1.505 $1,083.6
ml.g5.2xlarge
8vCPU / 32GB
A10G 24GB x 1 = 24GB $1.52 $1,094.4
ml.g5.4xlarge
16vCPU / 64GB
A10G 24GB x 1 = 24GB $2.03 $1,461.6
ml.g4dn.8xlarge
32vCPU / 128GB
T4 16GB x 1 = 16GB $2.72 $1,958.4
ml.g5.8xlarge
32vCPU / 128GB
A10G 24GB x 1 = 24GB $3.06 $2,203.2
ml.g4dn.16xlarge
64vCPU / 256GB
T4 16GB x 1 = 16GB $4.89 $3,520.8
ml.g5.16xlarge
64vCPU / 256GB
A10G 24GB x 1 = 24GB $5.12 $3,686.4
ml.g4dn.12xlarge
48vCPU / 192GB
T4 16GB x 4 = 64GB $5.44 $3,916.8
ml.g5.12xlarge
48vCPU / 192GB
A10G 24GB x 4 = 96GB $7.09 $5,104.8
ml.g5.24xlarge
96vCPU / 384GB
A10G 24GB x 4 = 96GB $10.18 $7,329.6
ml.g5.48xlarge
192vCPU / 768GB
A10G 24GB x 8 = 192GB $20.36 $14,659.2

まとめ

パラメーター数:3B

  • インスタンスタイプ: ml.g4dn.2xlarge
  • コンテナタイプ: HuggingFace Inference Container

約$700/月

パラメーター数:7B

  • インスタンスタイプ: ml.g4dn.12xlarge
  • コンテナタイプ: HuggingFace Text Generation Inference Container

約$4,000/月

パラメーター数:10B

  • インスタンスタイプ: ml.g5.12xlarge
  • コンテナタイプ: HuggingFace Text Generation Inference Container

約$5,100/月

パラメーター数:70B

検証中。

3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?