2017-06-15 49 views
1

在Ubuntu 16.04上運行最新(1.1.0)張量流(通過pip3 install tensorflow-gpu安裝),CUDA8 + CUDNN5。TF KMeansClustering不能在GPU上運行

代碼看起來或多或少是這樣的:

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

TensorFlow默認分配所有可用內存。 請參閱:https://stackoverflow.com/questions/34199233/how-to-prevent-tensorflow-from-allocating-the-totality-of-a-gpu-memory 它可能不在GPU上運行,因爲這沒有爲它編寫GPU內核。 – jkschin

+0

@jkschin是的我意識到內存分配模式 - 只是顯示了使用TF GPU的證明。至於gpu內核,我嘗試通過代碼,內部似乎使用了很多基本的TF操作,我認爲這應該在GPU上工作,但我不確定。 –

+0

你可以嘗試的一個實驗是斷言tf.device和沒有軟佈局,然後看看拋出了什麼錯誤? – jkschin

回答

0

通過代碼庫 - TF 1.1.0根本沒有GPU內核。