在Ubuntu 16.04上运行,最新(1.1.0)张量流(通过pip3 install tensorflow-gpu
安装),CUDA8 + CUDNN5。
代码看起来或多或少是这样的:
import tensorflow as tf
from tensorflow.contrib.learn import KMeansClustering
trainencflt = #pandas frame with ~30k rows and ~300 columns
def train_input_fn():
return (tf.constant(trainencflt, shape = [trainencflt.shape[0], trainencflt.shape[1]]), None)
configuration = tf.contrib.learn.RunConfig(log_device_placement=True)
model = KMeansClustering(num_clusters=k,
initial_clusters=KMeansClustering.RANDOM_INIT,
relative_tolerance=1e-8,
config=configuration)
model.fit(input_fn = train_input_fn, steps = 100)
当它运行时,我看到:
2017-06-15 10:24:41.564890: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 with properties:
name: GeForce GTX 1080
major: 6 minor: 1 memoryClockRate (GHz) 1.7335
pciBusID 0000:81:00.0
Total memory: 7.92GiB
Free memory: 7.81GiB
2017-06-15 10:24:41.564934: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0
2017-06-15 10:24:41.564942: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y
2017-06-15 10:24:41.564956: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:81:00.0)
分配内存:
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 1 548 C python 7745MiB |
+-----------------------------------------------------------------------------+
但是后来没有任何操作在GPU上执行(它始终保持在0%,CPU利用率在所有内核上都飙升):
+-----------------------------------------------------------------------------+
| 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. |
|===============================+======================+======================|
| 1 GeForce GTX 1080 Off | 0000:02:00.0 Off | N/A |
| 29% 43C P8 13W / 180W | 7747MiB / 8114MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
没有看到任何展示位置日志(即使我将log_device_placement
指定为True)。
我确实尝试了the simple GPU examples,他们工作得很好(至少放置日志看起来很好)。
我错过了什么吗?
答案 0 :(得分:0)
通过代码库 - TF 1.1.0根本就没有GPU内核。