Why doesn't my kera / tensor stream use GPUs

I looked at some other posts about this on stackoverflow, but nothing really helps. I installed only the tensorflow-gpu version and installed keras.

I checked that gpu was recognized, namely:

print(device_lib.list_local_devices())
print('Tensorflow: ', tf.__version__)

of

[name: "/cpu:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
 incarnation: 17474054933763055451
, name: "/gpu:0"
device_type: "GPU"
memory_limit: 52848230
locality {
  bus_id: 1
}
incarnation: 1990869997540085603
physical_device_desc: "device: 0, name: GeForce GTX 1070, pci bus id: 
0000:01:00.0"
]
Tensorflow:  1.3.0

But when I run the keras model using endorflow-back-end, it does not seem to be faster than when I run it on another computer using the tensorflow-cpu method without nvidia. Also looking at the task manager, I see a surge in CPU usage. I am new to this and trying to figure it all out, but shouldn't it work with the model / trace much faster? And shouldn't I see an increase in CPU usage if it uses GPUs?

- , . tensorflow-gpu, CUDA, cudnn ..

:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 387.92                 Driver Version: 387.92                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. | 


|   0  GeForce GTX 1070   WDDM  | 00000000:01:00.0  On |                  N/A |
| N/A   49C    P8     9W /  N/A |   7028MiB /  8192MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |


|    0      3740      C   C:\Users\Jason\Anaconda3\pythonw.exe       N/A      |
|    0      3968    C+G   ...dows.Cortana_cw5n1h2txyewy\SearchUI.exe N/A      |
|    0      4392    C+G   C:\Windows\explorer.exe                    N/A      |
|    0      7760    C+G   ...0.0_x64__8wekyb3d8bbwe\WinStore.App.exe N/A      |
|    0      8976    C+G   ...6)\Google\Chrome\Application\chrome.exe N/A      |
|    0      9932    C+G   ...rosoft Office\root\Office16\WINWORD.EXE N/A      |
|    0     12632    C+G   Insufficient Permissions                   N/A      |
|    0     14168    C+G   Insufficient Permissions                   N/A      |
|    0     14548    C+G   ...t_cw5n1h2txyewy\ShellExperienceHost.exe N/A      |
|    0     15648    C+G   Insufficient Permissions                   N/A      |
+-----------------------------------------------------------------------------+

:

C:\Program Files\NVIDIA Corporation\NVSMI>nvidia-smi
Fri Oct 13 13:18:23 2017
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 387.92                 Driver Version: 387.92                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |

|   0  GeForce GTX 1070   WDDM  | 00000000:01:00.0  On |                  N/A |
| N/A   51C    P2    34W /  N/A |   7126MiB /  8192MiB |     15%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |

|    0      3740      C   C:\Users\Jason\Anaconda3\pythonw.exe       N/A      |
|    0      3968    C+G   ...dows.Cortana_cw5n1h2txyewy\SearchUI.exe N/A      |
|    0      4392    C+G   C:\Windows\explorer.exe                    N/A      |
|    0      7760    C+G   ...0.0_x64__8wekyb3d8bbwe\WinStore.App.exe N/A      |
|    0      8976    C+G   ...6)\Google\Chrome\Application\chrome.exe N/A      |
|    0      9932    C+G   ...rosoft Office\root\Office16\WINWORD.EXE N/A      |
|    0     12632    C+G   Insufficient Permissions                   N/A      |
|    0     14168    C+G   Insufficient Permissions                   N/A      |
|    0     14548    C+G   ...t_cw5n1h2txyewy\ShellExperienceHost.exe N/A      |
|    0     15648    C+G   Insufficient Permissions                   N/A      |
+-----------------------------------------------------------------------------+

Anaconda Python 3.6; Tensorflow-gpu 1.3

  • Visual Studio 15 ( CUDA 8 17, VS 15)
  • CUDA v8.0: PATH
  • Nvidia
  • cudnn-v6.0 CUDA 8 5.1. Tensorflow 1.3 Cudnn-v6.0: PATH

UPDATE:

, . . Keras.

import numpy as np
from keras import models
from keras import layers
from keras.wrappers.scikit_learn import KerasRegressor
from sklearn.model_selection import GridSearchCV
import datetime

# Set random seed
np.random.seed(7)

# Create function returning a compiled network
def create_network(optimizer='adam',activation='relu'):

# Start neural network
network = models.Sequential()

# Add fully connected layer with a ReLU activation function
network.add(layers.Dense(units=dim, activation=activation, input_shape=(dim,)))

# Add fully connected layer with a ReLU activation function
network.add(layers.Dense(units=20, activation=activation))

# Add fully connected layer with a sigmoid activation function
network.add(layers.Dense(units=1, activation='linear'))

# Compile neural network
network.compile(loss='mse', # 
                optimizer=optimizer, # Optimizer
                metrics=['mae']) # Accuracy performance metric

# Return compiled network
return network

# Wrap Keras model so it can be used by scikit-learn
neural_network = KerasRegressor(build_fn=create_network, verbose=2)


# Create hyperparameter space
epochs = [5, 50, 100, 150]
batches = [1, 5, 10, 100]



# Create hyperparameter options
hyperparameters = dict(epochs=epochs, batch_size=batches)


# Time the process
start_time = datetime.datetime.now()

# Create grid search
grid = GridSearchCV(estimator=neural_network, param_grid=hyperparameters)

# Fit grid search
grid_result = grid.fit(X, Y)


# View hyperparameters of best neural network
grid_result.best_params_

# summarize results
print("Best: %f using %s" % (grid_result.best_score_, 
grid_result.best_params_))
means = grid_result.cv_results_['mean_test_score']
stds = grid_result.cv_results_['std_test_score']
params = grid_result.cv_results_['params']
for mean, stdev, param in zip(means, stds, params):
    print("%f (%f) with: %r" % (mean, stdev, param))

end_time = datetime.datetime.now()
processing_time = end_time - start_time
print(str(processing_time).split('.')[0])

2: , , -... , ... - , ?

scikit GridSearchCV. keras tensorflow, scikit-learn , ? , keras, , ?

+4

Source: https://habr.com/ru/post/1687454/


All Articles