Nicolas Boutry
Nicolas Boutry

Reputation: 41

Keras does not use my Nvidia GPU when training a neural network

My GPU is not used by Keras/TensorFlow.

To try to make my GPU working with tensorflow, I tried to install tensorflow-gpu (I am using Python 3.6.8 on Windows):

pip3 install tensorflow-gpu --user

python -m notebook

import tensorflow as tf

I got then the following errors:

ImportError ... Traceback (most recent call last),

ImportError: DLL load failed: Le module spécifié est introuvable.

ImportError ... Traceback (most recent call last)

Then I do pip3 install tensorflow, python - notebook, and then import tensorflow as tf works but when I continue with:

from tensorflow.python.client import device_lib

print(device_lib.list_local_devices())

print('Tensorflow: ', tf._ _ version _ _)

And I obtain:

[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 587921620497715868
]
Tensorflow:  1.13.1

It means that no GPU has been found (and I have an Intel UHD Graphics P630 and a Nvidia Quadro P5200 on my Lenovo Thinkpad P72).

Also, note that when I do !nvidia-smi I see that the Nvidia is detected (as GPU [0]), so I do not understand why Tensorflow/Keras do not use it when I train neural networks.

Thank your for your help.

Upvotes: 1

Views: 1011

Answers (1)

Nicolas Boutry
Nicolas Boutry

Reputation: 41

I think I solved the problem :)

After installing Anaconda3, I proceeded this way in the Anaconda powershell:

conda create -n tensorflowgpuproject python=3.5 tensorflow-gpu=1.10.0 ipython=6.5.0 keras matplotlib jupyter scikit-learn numpy=1.14.5 setuptools=39.1.0 prompt_toolkit=1.0.15

conda activate tensorflowgpuproject

python -m pip install --upgrade pip --user

setx path "%path%;C:\Users\n-bou\AppData\Roaming\Python\Python35\Scripts"

pip uninstall prompt_toolkit (the last command was necessary because there was a conflict between two versions of prompt_toolkit)

Then I was able to execute my python notebook containing the code of a UNet using keras with the usual "import tensorflow as tf" (calling tensorflow-gpu) at the beginning of the notebook.

Upvotes: 1

Related Questions