From 908c139c91167320b7c0f7dfadb239d44859d741 Mon Sep 17 00:00:00 2001 From: ebecht Date: Fri, 1 Nov 2019 13:39:18 -0700 Subject: [PATCH] Fixed CPU utilisation for NNs with neural_networks_seed = NULL --- DESCRIPTION | 2 +- R/04_regression_all.R | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5beb470..4b3e544 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: infinityFlow Title: Augmenting cytometry using massively parallel multivariate non-linear regressions -Version: 0.1.1 +Version: 0.1.2 Authors@R: c( person("Etienne","Becht",middle=NULL,email="etienne_becht@protonmail.com",role=c("cre","aut")) ) diff --git a/R/04_regression_all.R b/R/04_regression_all.R index b34da96..398bf9c 100755 --- a/R/04_regression_all.R +++ b/R/04_regression_all.R @@ -212,6 +212,12 @@ fit_regressions=function( library(glmnet) if(!is.null(neural_networks_seed)){ use_session_with_seed(neural_networks_seed) ## This will make results reproducible, disable GPU and CPU parallelism (which is good actually). Source: https://keras.rstudio.com/articles/faq.html#how-can-i-obtain-reproducible-results-using-keras-during-development + } else { + config <- list() + config$intra_op_parallelism_threads <- 1L + config$inter_op_parallelism_threads <- 1L + session_conf <- do.call(tf$ConfigProto, config) + sess <- tf$Session(graph = tf$get_default_graph(), config = session_conf) } } ) @@ -321,6 +327,12 @@ predict_from_models=function( xp=xp[,make.names(chans)] if(!is.null(neural_networks_seed)){ use_session_with_seed(neural_networks_seed) ## This will make results reproducible, disable GPU and CPU parallelism (which is good actually). Source: https://keras.rstudio.com/articles/faq.html#how-can-i-obtain-reproducible-results-using-keras-during-development + } else { + config <- list() + config$intra_op_parallelism_threads <- 1L + config$inter_op_parallelism_threads <- 1L + session_conf <- do.call(tf$ConfigProto, config) + sess <- tf$Session(graph = tf$get_default_graph(), config = session_conf) } } ))