简体   繁体   English

在训练神经网络时,Keras不使用我的Nvidia GPU

[英]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.

相关问题 Keras 看到我的 GPU 但在训练神经网络时不使用它 - Keras sees my GPU but doesn't use it when training a neural network 我的训练过程没有使用 Nvidia GPU - My training process does not use Nvidia GPU 在GPU上训练神经网络时如何解决OOM问题? - How to resolve OOM issues when training neural network on GPU? 在 Tensorflow 上训练卷积神经网络时 GPU 内存不足 - GPU out of memory when training convolutional neural network on Tensorflow 训练时 Keras 神经网络准确率始终为 0 - Keras Neural Network Accuracy is always 0 While Training 使用多个数据集训练神经网络 (Keras) - Training a Neural Network with Multiple Datasets (Keras) 为什么我的神经网络在训练后会做出如此不准确的预测? - Why does my neural network make such inaccurate predictions after training? 使用Pytorch训练神经网络时了解类的使用 - Understanding the use of classes when training a neural network with Pytorch 我的keras神经网络无法预测手写数字 - My keras neural network does not predict handwritten numbers 如何在Keras实施的卷积神经网络的训练过程中修复我的骰子损失计算? - How can I fix my dice loss calculation during the training process of a convolutional neural network implemented in Keras?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM