[英]Keras does not use my Nvidia GPU when training a neural network
My GPU is not used by Keras/TensorFlow. Keras / TensorFlow不使用我的GPU。
To try to make my GPU working with tensorflow, I tried to install tensorflow-gpu (I am using Python 3.6.8 on Windows): 为了尝试让我的GPU使用tensorflow,我尝试安装tensorflow-gpu(我在Windows上使用Python 3.6.8):
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: 然后我做
pip3 install tensorflow, python - notebook
,然后import tensorflow as tf
工作,但当我继续:
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). 这意味着没有找到GPU(我的联想Thinkpad P72上有一个Intel UHD Graphics P630和一个Nvidia Quadro P5200)。
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. 另外,请注意,当我这样做时!nvidia-smi我看到Nvidia被检测到(作为GPU [0]),所以我不明白为什么Tensorflow / Keras在训练神经网络时不使用它。
Thank your for your help. 谢谢你的帮助。
I think I solved the problem :) 我想我解决了这个问题:)
After installing Anaconda3, I proceeded this way in the Anaconda powershell: 安装Anaconda3之后,我在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 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 conda激活tensorflowgpuproject
python -m pip install --upgrade pip --user python -m pip install --upgrade pip --user
setx path "%path%;C:\\Users\\n-bou\\AppData\\Roaming\\Python\\Python35\\Scripts" setx路径“%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) pip uninstall prompt_toolkit(最后一个命令是必要的,因为两个版本的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. 然后我能够在笔记本开头使用常用的“import tensorflow as tf”(调用tensorflow-gpu)执行包含UNet代码的python笔记本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.