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?

めっちゃ時間がかかる pip install flash_attn をどのようにインストールしたか?

Posted at

課題: flash_attnのインストールにおいてメモリが足らなくなっている

原因は、内部的にninjaを用いた並列コンパイルを行っており、各プロセスがメモリを確保しているようで、結果としてメモリが足らなくなっていた。

pip install flash_attn

この後、別のターミナルでメモリ量を確認する

$ free -h
               total        used        free      shared  buff/cache   available
Mem:            56Gi        51Gi       5.0Gi       0.0Ki       269Mi       4.7Gi
Swap:          2.0Gi       1.5Gi       544Mi

以下に対策を示す。本質は対策2であり、実際は対策1は不要かも・・・

対策1: Swap量を増やす

SWAP を16GB に増やすこととした

sudo swapoff -a
sudo fallocate -l 16G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

以下でswapが増えたことを確認する

free -h

再起動すると、ものに戻るので注意

対策2: ninjaの並列数を調整する

並列数を今回4としているが、実際は並列数と消費メモリ量, 最大メモリ量と相談しながら決めること

export MAX_JOBS=4

pip install

pip install flash_attn -v
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?