LoginSignup
9
5

More than 5 years have passed since last update.

TensorFlow > GPUはあるけどメモリ制約の関係で使わない方法 > CUDA_VISIBLE_DEVICES=-1 python cifar10_train.py

Last updated at Posted at 2016-10-29
動作環境
Ubuntu 14.04 LTS desktop amd64
GeForce GTX 750 Ti
ASRock Z170M Pro4S [Intel Z170chipset]
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v7.5
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.

TensorFlowを遊び倒す! 4-1. Convolutional Neural Networks
http://blog.brainpad.co.jp/entry/2016/04/22/170000

CIFAR-10のデータセットを処理するTutorialを学習中。

http://qiita.com/7of9/items/b8286880b483f6468e27
においてGPU(GeForce GTX 750 Ti: 2GB)ではcifar10_train.pycifar10_eval.pyを同時実行はできないことがわかった。

CPU動作にしようとしてが、関連pythonファイルを変更してもうまくCPU動作にできなかった。

以下を見つけた。
TensorflowでGPUを制限・無効化する

http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-var
CUDAには環境変数CUDA_​VISIBLE_​DEVICESを用いてプログラムが利用できるGPUを制限する機能があります.

# GPU: 0だけ使う
$ CUDA_​VISIBLE_​DEVICES=0 python test_gpu.py

CPUだけ使うにはどうすればいいかわからないが、以下をやってみた。

$ CUDA_​VISIBLE_​DEVICES=-1 python cifar10_train.py

CPU動作になったようだ。これでpython cifar10_eval.pyを実行すると正常動作するようになった。

ただし上記の方法はただの思いつきなので、正式な方法ではないかもしれない。

関連 http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-vars

こちらのほうがいい

trainはGPUで動かす。

$ python cifar10_train.py

evalをCPUで動かす。

$  CUDA_VISIBLE_DEVICES=-1 cifar10_eval.py
9
5
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
9
5