Important: Read this before posting to this forum

  1. This forum is for questions related to the use of Apollo. We will answer some general choice modelling questions too, where appropriate, and time permitting. We cannot answer questions about how to estimate choice models with other software packages.
  2. There is a very detailed manual for Apollo available at http://www.ApolloChoiceModelling.com/manual.html. This contains detailed descriptions of the various Apollo functions, and numerous examples are available at http://www.ApolloChoiceModelling.com/examples.html. In addition, help files are available for all functions, using e.g. ?apollo_mnl
  3. Before asking a question on the forum, users are kindly requested to follow these steps:
    1. Check that the same issue has not already been addressed in the forum - there is a search tool.
    2. Ensure that the correct syntax has been used. For any function, detailed instructions are available directly in Apollo, e.g. by using ?apollo_mnl for apollo_mnl
    3. Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
    4. Make sure that R is using the latest official release of Apollo.
  4. If the above steps do not resolve the issue, then users should follow these steps when posting a question:
    1. provide full details on the issue, including the entire code and output, including any error messages
    2. posts will not immediately appear on the forum, but will be checked by a moderator first. This may take a day or two at busy times. There is no need to submit the post multiple times.

Error with Multi-threading model estimation

Report bugs or highlight issues with Apollo functions. At a minimum, please include the part of the output where you believe the bug is manifested. Ideally, please share your model file.
Post Reply
hrrichard
Posts: 10
Joined: 26 Apr 2020, 15:03

Error with Multi-threading model estimation

Post by hrrichard »

Dear Stephane and David,

I just updated Apollo to v.0.0.1.0 (R version is 4.0.0, R-studio version: Version 1.2.5042), and when I am trying to estimate a model with multiple cores, I receive the following error message:

Attempting to split data into 4 pieces.
Number of observations per worker (thread):
873, 873, 873, 873
Writing pieces to disk.... Done. 212.4MB of RAM in use.
Preparing workersError in makePSOCKcluster(names = spec, ...) :
Cluster setup failed. 4 of 4 workers failed to connect.


I wanted to see whether the problem was in my code, so I tried to estimate Apollo_example_14, but I received the same error message. Estimation with a single core runs without any issues. When I run the code in R instead of R-studio, there are no issues. Do you think there may be some compatibility issues with the latest version of R-studio?

Thanks for looking into this.

Best wishes,
Richard
dpalma
Posts: 190
Joined: 24 Apr 2020, 17:54

Re: Error with Multi-threading model estimation

Post by dpalma »

Hi Richárd,

Sadly, I am not familiar with the error you got. It is an error generated by the “parallel” package, and not from Apollo, so I can only guess at what the issue is.

Are you running R in windows? If so, the first time you use Apollo (or any other package) with multithreading you should get a message from windows requesting authorization for R to use network functionalities. You should allow R to access the network, as this is required for multi-threading to work.

If you are not working in Windows, then I am not sure what could be the cause. In any case, I would recommend uninstalling your current version of R, and re-installing the latest version.

Best wishes
David
hrrichard
Posts: 10
Joined: 26 Apr 2020, 15:03

Re: Error with Multi-threading model estimation

Post by hrrichard »

Hi David,

Thank you for your response. I was eventually able to solve the problem by downgrading from R-version 4.0.0 to R version is 3.6.3, and the Multi-threading model estimation now runs in R-studio as well.

Best wishes,
Richard
jjanmaat
Posts: 11
Joined: 01 Dec 2020, 20:01

Re: Error with Multi-threading model estimation

Post by jjanmaat »

I too have a problem with multithreading.

Error in apollo_makeLogLike(apollo_beta, apollo_fixed, apollo_probabilities, :
Model components are inconsistent across workers. Try seting apollo_control$nCores=1

This occurs when estimating a hybrid model with two latent variables, estimated using an ordered logit.

It occurs with R 4.1.0, but not with R 4.0.3. This was happening on Windows and not on Linux, but it now seems to have cropped up on Linux as well after I upgraded R.

John.
dpalma
Posts: 190
Joined: 24 Apr 2020, 17:54

Re: Error with Multi-threading model estimation

Post by dpalma »

Hi John,

Please try the following:
  1. Make sure you are using the latest version of Apollo. You can download the latest development version of Apollo from http://www.apollochoicemodelling.com/code.html. Note that you need to download the appropriate file for your operating system.
    If you are using RStudio, you install this file simply by selecting Tool > Install Packages... in the menu bar, and then selecting Install from: Package Archive File, and select the file you downloaded.
    If you are not using RStudio, then you can run:

    Code: Select all

    install.packages("C:/path/to/file/apollo_0.2.5.zip", repos=NULL)
    Where you need to change "C:/path/to/file/apollo_0.2.5.zip" to the appropriate path to the downloaded file.
    .
  2. Make sure you are not using tibble. tibble is a data.frame replacement used by tidyverse packages, and it is not fully compatible with Apollo. To make sure that your data is not a tibble, try running:

    Code: Select all

    if('tibble' %in% installed.packages()[,"Package"] && tibble::is_tibble(database)) database <- as.data.frame(database)
If none of those points solve the issue, please share your script and database so I can look into the issue in more detail. You can email them to me at D.Palma[at]leeds.ac.uk if you prefer.

Cheers
David
punyabeet
Posts: 19
Joined: 08 May 2020, 11:43

Re: Error with Multi-threading model estimation

Post by punyabeet »

Hi Prof David

I also get the same error message while estimating a nested ICLV model using multiple cores. This is what it shows -

Error in apollo_makeLogLike(apollo_beta, apollo_fixed, apollo_probabilities, :
Model components are inconsistent across workers. Try seting apollo_control$nCores=1

The model runs fine for only one core. Even the Nested Logit Model runs for any number of cores.

So how can I allocate multiple cores as my model is a bit complex and it takes a lot of time while using only a single core?

Thanks
Punya
dpalma
Posts: 190
Joined: 24 Apr 2020, 17:54

Re: Error with Multi-threading model estimation

Post by dpalma »

Hi Punya,

We recently released a new version of Apollo (v0.2.5). Please update to that version and try again. You can update simply by running:

Code: Select all

install.packages("apollo")
If the problem persists, please share your code and at least a few rows of your data with us, so that we can look at the problem in more detail. If that is the case, you can share the script and data either by attaching it to your response here in the forum, or you can email it to me to d.palma [at] leeds.ac.uk

Best wishes
David
Post Reply