相关疑难解决方法(0)

使用TensorFlow后端的Keras不使用GPU

我用keras版本2.0.0和tensorflow版本0.12.1构建了docker 镜像https://github.com/floydhub/dl-docker的gpu版本.然后我运行了mnist教程https://github.com/fchollet/keras/blob/master/examples/mnist_cnn.py,但意识到keras没有使用GPU.以下是我的输出

root@b79b8a57fb1f:~/sharedfolder# python test.py
Using TensorFlow backend.
Downloading data from https://s3.amazonaws.com/img-datasets/mnist.npz
x_train shape: (60000, 28, 28, 1)
60000 train samples
10000 test samples
Train on 60000 samples, validate on 10000 samples
Epoch 1/12
2017-09-06 16:26:54.866833: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-09-06 16:26:54.866855: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are …
Run Code Online (Sandbox Code Playgroud)

docker keras tensorflow tensorflow-gpu

12
推荐指数
2
解决办法
2万
查看次数

如何强制keras使用tensorflow GPU后端

我知道这是最受欢迎的问题之一,但到目前为止,没有一个解决方案对我有用。

tensorflow v1.13.1我正在运行用和编写的遗留代码keras v2.2.4。我无法修改代码来运行最新的张量流版本。由于 keras 现已合并到tensorflow中,因此我在通过pip安装特定版本的tensorflow和keras时遇到问题。我发现anaconda可以选择使用上述版本安装keras和tensorflow。所以,我安装了它

conda install -c conda-forge keras-gpu=2.2.4 tensorflow-gpu=1.13.1
Run Code Online (Sandbox Code Playgroud)

它安装了该版本并且一切正常。但它不使用 GPU,而是在 CPU 上运行。我注意到 anaconda 安装了 Tensorflow 的 CPU 和 GPU 版本,我想这就是它默认为 CPU 版本的原因。所以,我的问题是,如何强制它使用 GPU 版本?

PS:有很多答案建议删除CPU版本的tensorflow。但是当我尝试删除 CPU 版本时,conda 会卸载所有内容,包括 keras。所以,我认为当两者都安装时应该有一种使用tensorflow-gpu的方法。任何在这方面的帮助表示赞赏!

python keras tensorflow

5
推荐指数
1
解决办法
1264
查看次数

标签 统计

keras ×2

tensorflow ×2

docker ×1

python ×1

tensorflow-gpu ×1