How to use 8 cores while running LDA topic model in R









up vote
0
down vote

favorite












I am running a Latent Dirichlet topic model in R using the follwing code:



for(k in 2:30) 
ldaOut <-LDA(dtm,k, method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k, sep = "_"), ldaOut)



The dtm has 12 million elements, and each loop takes up to two hours on average. Meanwhile, R uses only 1 of my 8 logical processors ( i have i7-2700K CPU @ 3.50GHz wtih 4 cores). How can I make R use all the computational power available when I run one LDA topic model or when using a loop (as in this code)?



Thank you



EDIT: follwing gc_'s advice, I used the following code:



library(doParallel)

n.cores <- detectCores(all.tests = T, logical = T)
cl <- makePSOCKcluster(n.cores)

doParallel::registerDoParallel(cl)

burnin <- 4000
iter <- 2000
thin <- 500
seed <-list(2003,10,100,10005,765)
nstart <- 5
best <- TRUE

var.shared <- c("ldaOut", "dtm", "nstart", "seed", "best", "burnin", "iter", "thin", "n.cores")
library.shared <- "topicmodels" # Same for library or functions.


ldaOut <- c()

foreach (k = 2:(30 / n.cores - 1), .export = var.shared, .packages = library.shared) %dopar%
ret <- LDA(dtm, k*n.cores , method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k*n.cores, sep = "_"), ret)



The code ran without errors, but now there are 16 "R for Windows front-end" processes, 15 of which use 0% of the CPU and 1 is using 16-17%...And when the process was over i got this message:



A LDA_Gibbs topic model with 16 topics.

Warning messages:
1: In e$fun(obj, substitute(ex), parent.frame(), e$data) :
already exporting variable(s): dtm, nstart, seed, best, burnin, iter, thin, n.cores
2: closing unused connection 10 (<-MyPC:11888)
3: closing unused connection 9 (<-MyPC:11888)
4: closing unused connection 8 (<-MyPC:11888)
5: closing unused connection 7 (<-MyPC:11888)
6: closing unused connection 6 (<-MyPC:11888)
7: closing unused connection 5 (<-MyPC:11888)
8: closing unused connection 4 (<-MyPC:11888)
9: closing unused connection 3 (<-MyPC:11888)









share|improve this question























  • cran.r-project.org/web/views/HighPerformanceComputing.html
    – r2evans
    Nov 8 at 2:30










  • Have you tried text2vec package for topic model? It is faster. Please see below links:text2vec.org/topic_modeling.html and stackoverflow.com/questions/52268925/…
    – Sam S
    Nov 13 at 23:24















up vote
0
down vote

favorite












I am running a Latent Dirichlet topic model in R using the follwing code:



for(k in 2:30) 
ldaOut <-LDA(dtm,k, method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k, sep = "_"), ldaOut)



The dtm has 12 million elements, and each loop takes up to two hours on average. Meanwhile, R uses only 1 of my 8 logical processors ( i have i7-2700K CPU @ 3.50GHz wtih 4 cores). How can I make R use all the computational power available when I run one LDA topic model or when using a loop (as in this code)?



Thank you



EDIT: follwing gc_'s advice, I used the following code:



library(doParallel)

n.cores <- detectCores(all.tests = T, logical = T)
cl <- makePSOCKcluster(n.cores)

doParallel::registerDoParallel(cl)

burnin <- 4000
iter <- 2000
thin <- 500
seed <-list(2003,10,100,10005,765)
nstart <- 5
best <- TRUE

var.shared <- c("ldaOut", "dtm", "nstart", "seed", "best", "burnin", "iter", "thin", "n.cores")
library.shared <- "topicmodels" # Same for library or functions.


ldaOut <- c()

foreach (k = 2:(30 / n.cores - 1), .export = var.shared, .packages = library.shared) %dopar%
ret <- LDA(dtm, k*n.cores , method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k*n.cores, sep = "_"), ret)



The code ran without errors, but now there are 16 "R for Windows front-end" processes, 15 of which use 0% of the CPU and 1 is using 16-17%...And when the process was over i got this message:



A LDA_Gibbs topic model with 16 topics.

Warning messages:
1: In e$fun(obj, substitute(ex), parent.frame(), e$data) :
already exporting variable(s): dtm, nstart, seed, best, burnin, iter, thin, n.cores
2: closing unused connection 10 (<-MyPC:11888)
3: closing unused connection 9 (<-MyPC:11888)
4: closing unused connection 8 (<-MyPC:11888)
5: closing unused connection 7 (<-MyPC:11888)
6: closing unused connection 6 (<-MyPC:11888)
7: closing unused connection 5 (<-MyPC:11888)
8: closing unused connection 4 (<-MyPC:11888)
9: closing unused connection 3 (<-MyPC:11888)









share|improve this question























  • cran.r-project.org/web/views/HighPerformanceComputing.html
    – r2evans
    Nov 8 at 2:30










  • Have you tried text2vec package for topic model? It is faster. Please see below links:text2vec.org/topic_modeling.html and stackoverflow.com/questions/52268925/…
    – Sam S
    Nov 13 at 23:24













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am running a Latent Dirichlet topic model in R using the follwing code:



for(k in 2:30) 
ldaOut <-LDA(dtm,k, method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k, sep = "_"), ldaOut)



The dtm has 12 million elements, and each loop takes up to two hours on average. Meanwhile, R uses only 1 of my 8 logical processors ( i have i7-2700K CPU @ 3.50GHz wtih 4 cores). How can I make R use all the computational power available when I run one LDA topic model or when using a loop (as in this code)?



Thank you



EDIT: follwing gc_'s advice, I used the following code:



library(doParallel)

n.cores <- detectCores(all.tests = T, logical = T)
cl <- makePSOCKcluster(n.cores)

doParallel::registerDoParallel(cl)

burnin <- 4000
iter <- 2000
thin <- 500
seed <-list(2003,10,100,10005,765)
nstart <- 5
best <- TRUE

var.shared <- c("ldaOut", "dtm", "nstart", "seed", "best", "burnin", "iter", "thin", "n.cores")
library.shared <- "topicmodels" # Same for library or functions.


ldaOut <- c()

foreach (k = 2:(30 / n.cores - 1), .export = var.shared, .packages = library.shared) %dopar%
ret <- LDA(dtm, k*n.cores , method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k*n.cores, sep = "_"), ret)



The code ran without errors, but now there are 16 "R for Windows front-end" processes, 15 of which use 0% of the CPU and 1 is using 16-17%...And when the process was over i got this message:



A LDA_Gibbs topic model with 16 topics.

Warning messages:
1: In e$fun(obj, substitute(ex), parent.frame(), e$data) :
already exporting variable(s): dtm, nstart, seed, best, burnin, iter, thin, n.cores
2: closing unused connection 10 (<-MyPC:11888)
3: closing unused connection 9 (<-MyPC:11888)
4: closing unused connection 8 (<-MyPC:11888)
5: closing unused connection 7 (<-MyPC:11888)
6: closing unused connection 6 (<-MyPC:11888)
7: closing unused connection 5 (<-MyPC:11888)
8: closing unused connection 4 (<-MyPC:11888)
9: closing unused connection 3 (<-MyPC:11888)









share|improve this question















I am running a Latent Dirichlet topic model in R using the follwing code:



for(k in 2:30) 
ldaOut <-LDA(dtm,k, method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k, sep = "_"), ldaOut)



The dtm has 12 million elements, and each loop takes up to two hours on average. Meanwhile, R uses only 1 of my 8 logical processors ( i have i7-2700K CPU @ 3.50GHz wtih 4 cores). How can I make R use all the computational power available when I run one LDA topic model or when using a loop (as in this code)?



Thank you



EDIT: follwing gc_'s advice, I used the following code:



library(doParallel)

n.cores <- detectCores(all.tests = T, logical = T)
cl <- makePSOCKcluster(n.cores)

doParallel::registerDoParallel(cl)

burnin <- 4000
iter <- 2000
thin <- 500
seed <-list(2003,10,100,10005,765)
nstart <- 5
best <- TRUE

var.shared <- c("ldaOut", "dtm", "nstart", "seed", "best", "burnin", "iter", "thin", "n.cores")
library.shared <- "topicmodels" # Same for library or functions.


ldaOut <- c()

foreach (k = 2:(30 / n.cores - 1), .export = var.shared, .packages = library.shared) %dopar%
ret <- LDA(dtm, k*n.cores , method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k*n.cores, sep = "_"), ret)



The code ran without errors, but now there are 16 "R for Windows front-end" processes, 15 of which use 0% of the CPU and 1 is using 16-17%...And when the process was over i got this message:



A LDA_Gibbs topic model with 16 topics.

Warning messages:
1: In e$fun(obj, substitute(ex), parent.frame(), e$data) :
already exporting variable(s): dtm, nstart, seed, best, burnin, iter, thin, n.cores
2: closing unused connection 10 (<-MyPC:11888)
3: closing unused connection 9 (<-MyPC:11888)
4: closing unused connection 8 (<-MyPC:11888)
5: closing unused connection 7 (<-MyPC:11888)
6: closing unused connection 6 (<-MyPC:11888)
7: closing unused connection 5 (<-MyPC:11888)
8: closing unused connection 4 (<-MyPC:11888)
9: closing unused connection 3 (<-MyPC:11888)






r multicore lda






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 18:57

























asked Nov 8 at 2:19









Michael

708




708











  • cran.r-project.org/web/views/HighPerformanceComputing.html
    – r2evans
    Nov 8 at 2:30










  • Have you tried text2vec package for topic model? It is faster. Please see below links:text2vec.org/topic_modeling.html and stackoverflow.com/questions/52268925/…
    – Sam S
    Nov 13 at 23:24

















  • cran.r-project.org/web/views/HighPerformanceComputing.html
    – r2evans
    Nov 8 at 2:30










  • Have you tried text2vec package for topic model? It is faster. Please see below links:text2vec.org/topic_modeling.html and stackoverflow.com/questions/52268925/…
    – Sam S
    Nov 13 at 23:24
















cran.r-project.org/web/views/HighPerformanceComputing.html
– r2evans
Nov 8 at 2:30




cran.r-project.org/web/views/HighPerformanceComputing.html
– r2evans
Nov 8 at 2:30












Have you tried text2vec package for topic model? It is faster. Please see below links:text2vec.org/topic_modeling.html and stackoverflow.com/questions/52268925/…
– Sam S
Nov 13 at 23:24





Have you tried text2vec package for topic model? It is faster. Please see below links:text2vec.org/topic_modeling.html and stackoverflow.com/questions/52268925/…
– Sam S
Nov 13 at 23:24













1 Answer
1






active

oldest

votes

















up vote
1
down vote













You can use the library doParallel



library(doParallel)


To get the number of cores of your computer:



n.cores <- detectCores(all.tests = T, logical = T) 


You can see the distinction between logical and physical cores.



Now you need to assign the core and set up all the process:



cl <- makePSOCKcluster(n.cores) 
doParallel::registerDoParallel(cl)


You can create more processes than you have cores on your computer.
As R is creating new processes you need to define the library and variables you need to share with the workers.



var.shared <- c("ldaOut", "dtm", "nstart", "seed", "best", "burnin", "iter", "thin", "n.cores")
library.shared <- c() # Same for library or functions.


Then the loop will change to:



 ldaOut <- #Init the output#

foreach (k = 2:(30 / n.cores - 1), .export = var.shared, .packages = library.shared)) %dopar%
ret <- LDA(dtm, k*n.cores , method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k*n.cores, sep = "_"), ret)



I have never used LDA before so you might need to modify a bit the code above in order to make it works.






share|improve this answer






















  • thank you! I've tried this code, but got an error as shown above. It seems like the loop can't find the LDA function. Am I doing something wrong?
    – Michael
    Nov 8 at 4:08










  • Have you specified the library of the LDA function in library.shared?
    – gc_
    Nov 8 at 4:11










  • ok, i think i didin,t, so now I changed from "ldaOut <- #Init the output#" to "library.shared <- LDA", did i understand you correctly? with this line I get the error "Error in foreach(k = 2:(30/n.cores - 1), .export = var.shared, .packages = library.shared) : .packages must be a character vector"
    – Michael
    Nov 8 at 4:35










  • if the package name is LDA then library.shared <- "LDA". For ldaOut you need to initialize this variable with the object (but empty) as return the function LDA.
    – gc_
    Nov 8 at 6:07











  • gc_, the package name is "topicmodels", so i did the following "library.shared <- "topicmodels", and "ldaOut <- c()". With these modifications, I've been able to run the code without any errors, but R is using only 15-17 % of my CPU. There are 15 processes "R for windows front-end" using 0% and 1 using 16%.
    – Michael
    Nov 8 at 17:11











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53200635%2fhow-to-use-8-cores-while-running-lda-topic-model-in-r%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













You can use the library doParallel



library(doParallel)


To get the number of cores of your computer:



n.cores <- detectCores(all.tests = T, logical = T) 


You can see the distinction between logical and physical cores.



Now you need to assign the core and set up all the process:



cl <- makePSOCKcluster(n.cores) 
doParallel::registerDoParallel(cl)


You can create more processes than you have cores on your computer.
As R is creating new processes you need to define the library and variables you need to share with the workers.



var.shared <- c("ldaOut", "dtm", "nstart", "seed", "best", "burnin", "iter", "thin", "n.cores")
library.shared <- c() # Same for library or functions.


Then the loop will change to:



 ldaOut <- #Init the output#

foreach (k = 2:(30 / n.cores - 1), .export = var.shared, .packages = library.shared)) %dopar%
ret <- LDA(dtm, k*n.cores , method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k*n.cores, sep = "_"), ret)



I have never used LDA before so you might need to modify a bit the code above in order to make it works.






share|improve this answer






















  • thank you! I've tried this code, but got an error as shown above. It seems like the loop can't find the LDA function. Am I doing something wrong?
    – Michael
    Nov 8 at 4:08










  • Have you specified the library of the LDA function in library.shared?
    – gc_
    Nov 8 at 4:11










  • ok, i think i didin,t, so now I changed from "ldaOut <- #Init the output#" to "library.shared <- LDA", did i understand you correctly? with this line I get the error "Error in foreach(k = 2:(30/n.cores - 1), .export = var.shared, .packages = library.shared) : .packages must be a character vector"
    – Michael
    Nov 8 at 4:35










  • if the package name is LDA then library.shared <- "LDA". For ldaOut you need to initialize this variable with the object (but empty) as return the function LDA.
    – gc_
    Nov 8 at 6:07











  • gc_, the package name is "topicmodels", so i did the following "library.shared <- "topicmodels", and "ldaOut <- c()". With these modifications, I've been able to run the code without any errors, but R is using only 15-17 % of my CPU. There are 15 processes "R for windows front-end" using 0% and 1 using 16%.
    – Michael
    Nov 8 at 17:11















up vote
1
down vote













You can use the library doParallel



library(doParallel)


To get the number of cores of your computer:



n.cores <- detectCores(all.tests = T, logical = T) 


You can see the distinction between logical and physical cores.



Now you need to assign the core and set up all the process:



cl <- makePSOCKcluster(n.cores) 
doParallel::registerDoParallel(cl)


You can create more processes than you have cores on your computer.
As R is creating new processes you need to define the library and variables you need to share with the workers.



var.shared <- c("ldaOut", "dtm", "nstart", "seed", "best", "burnin", "iter", "thin", "n.cores")
library.shared <- c() # Same for library or functions.


Then the loop will change to:



 ldaOut <- #Init the output#

foreach (k = 2:(30 / n.cores - 1), .export = var.shared, .packages = library.shared)) %dopar%
ret <- LDA(dtm, k*n.cores , method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k*n.cores, sep = "_"), ret)



I have never used LDA before so you might need to modify a bit the code above in order to make it works.






share|improve this answer






















  • thank you! I've tried this code, but got an error as shown above. It seems like the loop can't find the LDA function. Am I doing something wrong?
    – Michael
    Nov 8 at 4:08










  • Have you specified the library of the LDA function in library.shared?
    – gc_
    Nov 8 at 4:11










  • ok, i think i didin,t, so now I changed from "ldaOut <- #Init the output#" to "library.shared <- LDA", did i understand you correctly? with this line I get the error "Error in foreach(k = 2:(30/n.cores - 1), .export = var.shared, .packages = library.shared) : .packages must be a character vector"
    – Michael
    Nov 8 at 4:35










  • if the package name is LDA then library.shared <- "LDA". For ldaOut you need to initialize this variable with the object (but empty) as return the function LDA.
    – gc_
    Nov 8 at 6:07











  • gc_, the package name is "topicmodels", so i did the following "library.shared <- "topicmodels", and "ldaOut <- c()". With these modifications, I've been able to run the code without any errors, but R is using only 15-17 % of my CPU. There are 15 processes "R for windows front-end" using 0% and 1 using 16%.
    – Michael
    Nov 8 at 17:11













up vote
1
down vote










up vote
1
down vote









You can use the library doParallel



library(doParallel)


To get the number of cores of your computer:



n.cores <- detectCores(all.tests = T, logical = T) 


You can see the distinction between logical and physical cores.



Now you need to assign the core and set up all the process:



cl <- makePSOCKcluster(n.cores) 
doParallel::registerDoParallel(cl)


You can create more processes than you have cores on your computer.
As R is creating new processes you need to define the library and variables you need to share with the workers.



var.shared <- c("ldaOut", "dtm", "nstart", "seed", "best", "burnin", "iter", "thin", "n.cores")
library.shared <- c() # Same for library or functions.


Then the loop will change to:



 ldaOut <- #Init the output#

foreach (k = 2:(30 / n.cores - 1), .export = var.shared, .packages = library.shared)) %dopar%
ret <- LDA(dtm, k*n.cores , method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k*n.cores, sep = "_"), ret)



I have never used LDA before so you might need to modify a bit the code above in order to make it works.






share|improve this answer














You can use the library doParallel



library(doParallel)


To get the number of cores of your computer:



n.cores <- detectCores(all.tests = T, logical = T) 


You can see the distinction between logical and physical cores.



Now you need to assign the core and set up all the process:



cl <- makePSOCKcluster(n.cores) 
doParallel::registerDoParallel(cl)


You can create more processes than you have cores on your computer.
As R is creating new processes you need to define the library and variables you need to share with the workers.



var.shared <- c("ldaOut", "dtm", "nstart", "seed", "best", "burnin", "iter", "thin", "n.cores")
library.shared <- c() # Same for library or functions.


Then the loop will change to:



 ldaOut <- #Init the output#

foreach (k = 2:(30 / n.cores - 1), .export = var.shared, .packages = library.shared)) %dopar%
ret <- LDA(dtm, k*n.cores , method="Gibbs",
control=list(nstart=nstart, seed = seed, best=best,
burnin = burnin, iter = iter, thin=thin))
assign(paste("ldaOut", k*n.cores, sep = "_"), ret)



I have never used LDA before so you might need to modify a bit the code above in order to make it works.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 8 at 2:53

























answered Nov 8 at 2:47









gc_

713




713











  • thank you! I've tried this code, but got an error as shown above. It seems like the loop can't find the LDA function. Am I doing something wrong?
    – Michael
    Nov 8 at 4:08










  • Have you specified the library of the LDA function in library.shared?
    – gc_
    Nov 8 at 4:11










  • ok, i think i didin,t, so now I changed from "ldaOut <- #Init the output#" to "library.shared <- LDA", did i understand you correctly? with this line I get the error "Error in foreach(k = 2:(30/n.cores - 1), .export = var.shared, .packages = library.shared) : .packages must be a character vector"
    – Michael
    Nov 8 at 4:35










  • if the package name is LDA then library.shared <- "LDA". For ldaOut you need to initialize this variable with the object (but empty) as return the function LDA.
    – gc_
    Nov 8 at 6:07











  • gc_, the package name is "topicmodels", so i did the following "library.shared <- "topicmodels", and "ldaOut <- c()". With these modifications, I've been able to run the code without any errors, but R is using only 15-17 % of my CPU. There are 15 processes "R for windows front-end" using 0% and 1 using 16%.
    – Michael
    Nov 8 at 17:11

















  • thank you! I've tried this code, but got an error as shown above. It seems like the loop can't find the LDA function. Am I doing something wrong?
    – Michael
    Nov 8 at 4:08










  • Have you specified the library of the LDA function in library.shared?
    – gc_
    Nov 8 at 4:11










  • ok, i think i didin,t, so now I changed from "ldaOut <- #Init the output#" to "library.shared <- LDA", did i understand you correctly? with this line I get the error "Error in foreach(k = 2:(30/n.cores - 1), .export = var.shared, .packages = library.shared) : .packages must be a character vector"
    – Michael
    Nov 8 at 4:35










  • if the package name is LDA then library.shared <- "LDA". For ldaOut you need to initialize this variable with the object (but empty) as return the function LDA.
    – gc_
    Nov 8 at 6:07











  • gc_, the package name is "topicmodels", so i did the following "library.shared <- "topicmodels", and "ldaOut <- c()". With these modifications, I've been able to run the code without any errors, but R is using only 15-17 % of my CPU. There are 15 processes "R for windows front-end" using 0% and 1 using 16%.
    – Michael
    Nov 8 at 17:11
















thank you! I've tried this code, but got an error as shown above. It seems like the loop can't find the LDA function. Am I doing something wrong?
– Michael
Nov 8 at 4:08




thank you! I've tried this code, but got an error as shown above. It seems like the loop can't find the LDA function. Am I doing something wrong?
– Michael
Nov 8 at 4:08












Have you specified the library of the LDA function in library.shared?
– gc_
Nov 8 at 4:11




Have you specified the library of the LDA function in library.shared?
– gc_
Nov 8 at 4:11












ok, i think i didin,t, so now I changed from "ldaOut <- #Init the output#" to "library.shared <- LDA", did i understand you correctly? with this line I get the error "Error in foreach(k = 2:(30/n.cores - 1), .export = var.shared, .packages = library.shared) : .packages must be a character vector"
– Michael
Nov 8 at 4:35




ok, i think i didin,t, so now I changed from "ldaOut <- #Init the output#" to "library.shared <- LDA", did i understand you correctly? with this line I get the error "Error in foreach(k = 2:(30/n.cores - 1), .export = var.shared, .packages = library.shared) : .packages must be a character vector"
– Michael
Nov 8 at 4:35












if the package name is LDA then library.shared <- "LDA". For ldaOut you need to initialize this variable with the object (but empty) as return the function LDA.
– gc_
Nov 8 at 6:07





if the package name is LDA then library.shared <- "LDA". For ldaOut you need to initialize this variable with the object (but empty) as return the function LDA.
– gc_
Nov 8 at 6:07













gc_, the package name is "topicmodels", so i did the following "library.shared <- "topicmodels", and "ldaOut <- c()". With these modifications, I've been able to run the code without any errors, but R is using only 15-17 % of my CPU. There are 15 processes "R for windows front-end" using 0% and 1 using 16%.
– Michael
Nov 8 at 17:11





gc_, the package name is "topicmodels", so i did the following "library.shared <- "topicmodels", and "ldaOut <- c()". With these modifications, I've been able to run the code without any errors, but R is using only 15-17 % of my CPU. There are 15 processes "R for windows front-end" using 0% and 1 using 16%.
– Michael
Nov 8 at 17:11


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53200635%2fhow-to-use-8-cores-while-running-lda-topic-model-in-r%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ