gpt4 book ai didi

tensorflow - PyCharm 中的 Keras 不使用 GPU

转载 作者:行者123 更新时间:2023-12-02 00:57:11 25 4
gpt4 key购买 nike

这些线程没有解决我的问题:
Keras does not use GPU on Pycharm having python 3.5 and Tensorflow 1.4

Keras with TensorFlow backend not using GPU

我已经在运行 Windows 10 并具有 GTX 750 Ti 显卡的 PC 上安装了 Tensorflow 和 Tensorflow-gpu (v.1.12.0),因此它确实支持 CUDA。我还安装了 CUDA Toolkit v10 和 cuDNN 库,当我运行时 nvcc -V在命令提示符下,我得到:

nvcc: NVIDIA (R) Cuda compiler...



我正在使用 PyCharm,在 CPU 上运行 Keras 没有任何问题。但它不使用我的 GPU。

当我打字
from keras import backend as K
K.tensorflow_backend._get_available_gpus()

它说

2018-11-25 10:47:57.448275: I tensorflow/core/platform/cpu_feature_gaurd.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

[ ]



我试过的:

1)我尝试卸载 Tensorflow 和 Tensorflow-gpu 并像上述线程所说的那样重新安装 Tensorflow-gpu。不起作用,我的代码不再在 CPU 上运行,并给出了有关 Tensorflow 的错误。一旦我重新安装了 Tensorflow,它又可以了。

2)我尝试使用名为 Theano 的库,Keras 官方文档 here 中提到了该库。 .当我添加以下几行时
import theano
theano.config.device='gpu'
theano.config.floatX='float32'

它说

WARNING (theano.configdefaults): g++ not available, if using conda: 'conda install m2w64-toolchain' C:\Users\HOME-PC\PyCharmProjects\env\lib\site-packages\theano\configdefaults.py.=:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with theano 0.11 a c++ compiler will be mandatory. warning.warn("DeprecationWarning: there is no c++ compiler."



3)我尝试添加这些行,但也没有发生任何事情。
import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"]="0"

我在这里缺少什么?我应该如何将 CUDA 引入 PyCharm?

最佳答案

问题出在 CUDA 的版本上。我已经安装了 CUDA v10.0,但 Tensorflow 似乎只适用于 v9.0。安装它,它就像一个魅力。

关于tensorflow - PyCharm 中的 Keras 不使用 GPU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53465477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com