Reputation: 13
I have a couple of questions about a statefull cuDNN LSTM model I'm trying to fit in R using keras library. I have tensorflow-gpu installed and it seems to be running sucessfully. The first thing I'm wondering about is the speed of model training which only seems to increase by a factor 1.3 using cuDNN lstm instead of ordinary LSTM. I have read other cases where people got models that train 10 or even 15 times faster when using cudnn lstm compared to normal lstm. I will post some code below. Moreover I'm wondering about the percentage of memory usage of GPU. When code is run, it only seems to take roughly 8 % of GPU memory which seems a bit low. Can this be connected with the lack of increased speed.
dim(x.train) = (208, 1, 4) dim(y.train) = (208 , 1)
For validation sets its the same except tat 208 is replaced with 42.
batch_size = 1
model <- keras_model_sequential()
model %>% layer_cudnn_lstm(units = 1, batch_input_shape = c(1,1,4),
stateful = TRUE, return_sequences = FALSE) %>%
layer_dropout(rate = dropout) %>%
layer_dense(units = 0.01)
model %>% compile(
loss = 'mean_squared_error',
optimizer = optimizer_adam(lr= 0.01, decay = 1e-8),
metrics = c('mean_squared_error')
)
Epochs <- 500
hist_temp <- model %>% fit(x.train, y.train, epochs=1, batch_size=batch_size, verbose=1, shuffle=FALSE,
validation_data = list(x.train_val, y.test))
model %>% reset_states()
Im expecting it to be much faster and more demanding on the GPU memory. What have I missed here?
Upvotes: 0
Views: 1102
Reputation: 802
this could have multiple reasons for example:
2.You have a very small network so that you don't profit from GPU accleration as much. You can try to increase the size of the network to test if the GPU usage increases.
I hope this helps.
Upvotes: 1