我内置泊坞窗图像的GPU版本https://github.com/floydhub/dl-docker与keras版本2.0.0和tensorflow版本0.12.1。 然后我跑了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 available on your machine and could speed up CPU computations.
2017-09-06 16:26:54.866863: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-09-06 16:26:54.866870: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-09-06 16:26:54.866876: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
任何人都可以让我知道,如果有一些需要keras使用GPU之前要进行的设置? 我是很新的这一切所以不要让我知道如果我需要提供更多的信息。
我已经安装了先决条件上提到页
- 下面的安装指南平台安装泊坞窗: https://docs.docker.com/engine/installation/
我能够启动泊坞窗图像
docker run -it -p 8888:8888 -p 6006:6006 -v /sharedfolder:/root/sharedfolder floydhub/dl-docker:cpu bash
- GPU版:无论是来自Nvidia直接安装在机器上的Nvidia驱动程序或者按照指示在这里 。 请注意,您不必安装CUDA或cuDNN。 这些都包含在泊坞窗容器。
我能够运行的最后一步
cv@cv-P15SM:~$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module 375.66 Mon May 1 15:29:16 PDT 2017
GCC version: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
- GPU版:安装NVIDIA-泊坞窗: https://github.com/NVIDIA/nvidia-docker ,这里的操作说明。 这将安装在泊坞窗CLI的替代品。 这需要建立Docker容器和其他一些东西里面Nvidia的主机驱动程序环境的关怀。
我能够运行步骤在这里
# Test nvidia-smi
cv@cv-P15SM:~$ nvidia-docker run --rm nvidia/cuda nvidia-smi
Thu Sep 7 00:33:06 2017
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.66 Driver Version: 375.66 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 780M Off | 0000:01:00.0 N/A | N/A |
| N/A 55C P0 N/A / N/A | 310MiB / 4036MiB | N/A Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 Not Supported |
+-----------------------------------------------------------------------------+
我也可以运行NVIDIA-泊坞窗命令来启动一个GPU支持的图像。
我曾尝试
我曾尝试下面的建议如下
- 请检查您是否已经完成了本教程(的第9步https://github.com/ignaciorlando/skinner/wiki/Keras-and-TensorFlow-installation )。 注意:您的文件路径可能是搬运工图像内完全不同的,你必须以某种方式找到他们。
我建议行追加到我的.bashrc和已验证的.bashrc文件被更新。
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64:/usr/local/cuda-8.0/extras/CUPTI/lib64' >> ~/.bashrc
echo 'export CUDA_HOME=/usr/local/cuda-8.0' >> ~/.bashrc
要导入在我的Python文件中的以下命令
import os os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID" # see issue #152 os.environ["CUDA_VISIBLE_DEVICES"]="0"
这两个步骤,单独或共同完成遗憾的是没有解决的问题。 Keras仍与tensorflow的CPU版本作为其后端运行。 不过,我可能已经找到了可能的问题。 我通过以下命令检查我tensorflow的版本,发现两个人。
这是CPU版本
root@08b5fff06800:~# pip show tensorflow
Name: tensorflow
Version: 1.3.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /usr/local/lib/python2.7/dist-packages
Requires: tensorflow-tensorboard, six, protobuf, mock, numpy, backports.weakref, wheel
这是GPU版本
root@08b5fff06800:~# pip show tensorflow-gpu
Name: tensorflow-gpu
Version: 0.12.1
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /usr/local/lib/python2.7/dist-packages
Requires: mock, numpy, protobuf, wheel, six
有趣的是,输出显示keras使用tensorflow版本1.3.0这是CPU版本,而不是0.12.1中,GPU版本
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K
import tensorflow as tf
print('Tensorflow: ', tf.__version__)
产量
root@08b5fff06800:~/sharedfolder# python test.py
Using TensorFlow backend.
Tensorflow: 1.3.0
我现在想我需要弄清楚如何有keras使用tensorflow的GPU版本。