As keras use mxnet as backend, I can not use the GPU to train .
For bugs or installation issues, please provide the following information. The more information you provide, the more likely people will be able to help you.
Environment info
Operating System: ubuntu16.04
Compiler:
Package used (Python/R/Scala/Julia):Python2.7
MXNet version: mxnet 0.11.0rc2
Or if installed from source:mxnet 0.11.0rc2
MXNet commit hash (git rev-parse HEAD):
If you are using python package, please provide
Python version and distribution:
If you are using R package, please provide
R sessionInfo():
Error Message:
Please paste the full error message, including stack trace. [22:01:04] G:\mxnet-cpp\mxnet20170819\mxnet\src\storage\storage.cc:109: Check failed: e == cudaSuccess || e == cudaErrorCudartUnloading CUDA: no CUDA-capable device is detected
Minimum reproducible example
if you are using your own code, please provide a short script that reproduces the error. \keras\examples\mnist_mlp.py
model = Sequential() model.add(Dense(512, input_shape=(784,))) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(512)) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(10)) model.add(Activation('softmax'))
model.summary()
gpu_list = ["gpu(0)"] model.compile(loss='categorical_crossentropy', optimizer=SGD(), context=gpu_list, ##Remove this line, we use cpu to train. metrics=['accuracy'])
Steps to reproduce
or if you are running standard examples, please provide the commands you have run that lead to the error.
- I run the sample named mnist_mlp.py . When I use cpu, it works. When I try it with GPU, it does not work.
- I write some codes to test the gpu function in mxnet, it works. The codes are like these: import mxnet as mx a = mx.nd.ones((2, 3), mx.gpu())
3.
What have you tried to solve it?
- I tried to compile the source codes . Then I tried again. I got the same errors. My cuda version is 8.0. In gpu mode, tensorflow and mxnet are ok. But when keras use mxnet as backend, I can not use the GPU to train .
@sandeep-krishnamurthy
Your Keras code looks fine. Can you please confirm if you have installed/compiled MXNet with GPU support and have installed NVIDIA drivers? Here is the detailed installation guide for your reference - https://github.com/dmlc/keras/wiki/Installation
Also can you provide your full code? I tried with https://github.com/dmlc/keras/blob/master/examples/mnist_mlp.py example by setting the context to gpu and it seems to work fine.
Sorry, it is my mistake. My codes has some bug like these : os.environ['CUDA_VISIBLE_DEVICES']='1' When I remove this line, everything is ok.
I love the mxnet as the keras backend. It is great!