Using Keras and GPU
I am using keras 1.1.0 with Theano support. To use the GPU, I installed os.envorn as:
os.environ['THEANO_FLAGS'] = "device=gpu0"
before importing kera. Importing keras gives me the following message:
Using gpu device 0: TITAN X (Pascal) (CNMeM is disabled, cuDNN 5105)
/home/library_python/lib/python/Theano-0.8.2-py2.7.egg/theano/sandbox/cuda/__init__.py:600: UserWarning: Your cuDNN version is more recent than the one Theano officially supports. If you see any problems, try updating Theano or downgrading cuDNN to version 5.
warnings.warn(warn)
So, I thought I had configured the device correctly. However, when I train the model with keras, nvidia-smi shows the following message:
Fri May 5 13:05:33 2017
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.51 Driver Version: 375.51 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GT 730 On | 0000:01:00.0 N/A | N/A |
| 30% 38C P8 N/A / N/A | 56MiB / 980MiB | N/A Default |
+-------------------------------+----------------------+----------------------+
| 1 TITAN X (Pascal) On | 0000:02:00.0 Off | N/A |
| 36% 63C P2 87W / 250W | 373MiB / 12189MiB | 35% Default |
+-------------------------------+----------------------+----------------------+
| 2 TITAN X (Pascal) On | 0000:03:00.0 Off | N/A |
| 23% 42C P8 18W / 250W | 3MiB / 12189MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 Not Supported |
| 1 1520 C /usr/bin/python 155MiB |
| 1 14996 C python 215MiB |
+-----------------------------------------------------------------------------+
It says I am using 215MB of GPU memory. I was expecting more than 10GB of usage. Could you tell me what I am doing wrong? Is the GPU device setting configured correctly?
+3
source to share
1 answer
The problem is solved after changing Theano_flag as:
os.environ['THEANO_FLAGS'] = "device=gpu0,floatX=float32,lib.cnmem=1"
I am now using 11.7G memory as expected.
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.51 Driver Version: 375.51 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GT 730 On | 0000:01:00.0 N/A | N/A |
| 30% 38C P8 N/A / N/A | 56MiB / 980MiB | N/A Default |
+-------------------------------+----------------------+----------------------+
| 1 TITAN X (Pascal) On | 0000:02:00.0 Off | N/A |
| 28% 47C P2 78W / 250W | 11923MiB / 12189MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 2 TITAN X (Pascal) On | 0000:03:00.0 Off | N/A |
| 23% 42C P8 18W / 250W | 3MiB / 12189MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 Not Supported |
| 1 1520 C /usr/bin/python 155MiB |
| 1 15543 C python 11765MiB |
+-----------------------------------------------------------------------------+
0
source to share