https://github.com/yenchenlin/pix2pix-tensorflow
のpix2pixをGoogle Colaboratoryで試そうと思い、環境を準備して実行していた.
が、ひたすらGPUメモリが確保できない!ってエラーが連発した.(OOM when allocating tensor of shape [X, X, X, X] and type float ResourceExhaustedError)
ググったら、以下のスレッドでいろいろと議論があってどうも「みんなで共有しているから常に11GBもらえるわけではないのでは ?」という話(多分嘘?本人曰くいつも500MBしかないとのことだが、おそらくバックグラウンドで何かを実行していまっている.)や「他に実行しちゃっているものがあるなら一度綺麗にした方がいい」って書いている話があった.
https://stackoverflow.com/questions/48750199/google-colaboratory-misleading-information-about-its-gpu-only-5-ram-available
上記に以下のような確認用スクリプトを貼ってくれているので、実行してみるとメモリの様子がわかる.
以下みたいな出力
Collecting gputil Downloading https://files.pythonhosted.org/packages/45/99/837428d26b47ebd6b66d6e1b180e98ec4a557767a93a81a02ea9d6242611/GPUtil-1.3.0.tar.gz Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from gputil) (1.14.5) Building wheels for collected packages: gputil Running setup.py bdist_wheel for gputil … done Stored in directory: /content/.cache/pip/wheels/17/0f/04/b79c006972335e35472c0b835ed52bfc0815258d409f560108 Successfully built gputil Installing collected packages: gputil Successfully installed gputil-1.3.0 Requirement already satisfied: psutil in /usr/local/lib/python3.6/dist-packages (5.4.6) Collecting humanize Downloading https://files.pythonhosted.org/packages/8c/e0/e512e4ac6d091fc990bbe13f9e0378f34cf6eecd1c6c268c9e598dcf5bb9/humanize-0.5.1.tar.gz Building wheels for collected packages: humanize Running setup.py bdist_wheel for humanize … done Stored in directory: /content/.cache/pip/wheels/69/86/6c/f8b8593bc273ec4b0c653d3827f7482bb2001a2781a73b7f44 Successfully built humanize Installing collected packages: humanize Successfully installed humanize-0.5.1 Gen RAM Free: 12.7 GB | Proc size: 139.4 MB GPU RAM Free: 11438MB | Used: 1MB | Util 0% | Total 11439MB
対応
私は225MBぐらいしかなく95%Usedみたいな状態だった.
たぶんバックグラウンドで以前に実行したプログラムが落ち切らずに動いている???
上のメモリチェックでおかしいことに気付けて、上記のスレッドに書かれていた”!kill -9 -1″を実行してプログラムを落として再度「Connected」になるようにした.これを行うとどうも初期化状態になるみたいで、再度環境のセットアップからやり直しすることになった.
killしてセットアップしなおしたらなんと上記のようにUsedd1MBという正常値に戻りました…なんだったんだ….