James-Thorson-NOAA / VAST

Spatio-temporal analysis of univariate or multivariate data, e.g., standardizing data for multiple species or stages
http://www.FishStats.org
GNU General Public License v3.0
123 stars 53 forks source link

VAST v5 compilation errors #140

Open mintoc opened 5 years ago

mintoc commented 5 years ago

On Ubuntu 18.04 and using gcc version 7.3.0 I can compile up to VAST_v4_4_0.cpp but can't compile more recent versions (sessionInfo() pasted below).

Using the R code

setwd(system.file("executables", package = "VAST"))
TMB::compile("VAST_v5_3_0.cpp")

I get lots of messages but two main errors:

error: no matching function for call to ‘isfinite(const CppAD::AD<double>&)’
error: no type named ‘__type’ in ‘struct __gnu_cxx::__enable_if<false, bool>’

I tried a diff on VAST_v4_4_0 and VAST_v5_0_0 and see there are a good many changes to the eigenvalue code, perhaps the errors arise there?

Thanks for your help.

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_IE.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_IE.UTF-8        LC_COLLATE=en_IE.UTF-8    
 [5] LC_MONETARY=en_IE.UTF-8    LC_MESSAGES=en_IE.UTF-8   
 [7] LC_PAPER=en_IE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_IE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.0.0        VAST_2.0.1           FishStatsUtils_1.0.0
[4] TMB_1.7.15          

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0       bindr_0.1.1      magrittr_1.5     tidyselect_0.2.5
 [5] munsell_0.5.0    colorspace_1.3-2 lattice_0.20-35  R6_2.3.0        
 [9] rlang_0.3.0.1    plyr_1.8.4       dplyr_0.7.7      tools_3.5.1     
[13] grid_3.5.1       gtable_0.2.0     withr_2.1.2      lazyeval_0.2.1  
[17] assertthat_0.2.0 tibble_1.4.2     crayon_1.3.4     Matrix_1.2-15   
[21] bindrcpp_0.2.2   purrr_0.2.5      glue_1.3.0       compiler_3.5.1  
[25] pillar_1.3.0     scales_1.0.0     pkgconfig_2.0.2 
pdolder commented 5 years ago

Cóilín/Jim - I'm having the same problem on Ubuntu with gcc 7.3.0. I've also had problems trying to compile the simple TMB sam.cpp example....

Might not be the best solution, but as a workround I've just got VAST 5.3.0 to compile by stepping back gcc versions... i.e. in your/or create a ~/.R/Makevar add:

CXX = gcc-5

(or whatever flavour you have installed).

James-Thorson commented 5 years ago

Paul and Coilin,

are you willing to post the issues you've seen to the TMB issue tracker for someone else who understands compiler-specific issues to look at? I'm also happy to reach out to Kasper myself, but don't feel like I have enough information right now.

Jim

jkbest2 commented 5 years ago

This should be resolved by kaskr/adcomp#298.

James-Thorson-NOAA commented 5 years ago

John,

can you help me understand this? I can see in their error message report that it involves isfinite and I gather that Kasper has now repaired something about that function. But do you know where it was being used in VAST -- perhaps its buried somewhere in the statement vector< std::complex<Type> > eigenvalues_B_ff = B_ff.eigenvalues(); of somewhere else involving the eigendecomposition of B_ff? And do you know if users then must update their TMB package to access this fix?

I could never replicate the problem so I'm not sure how to double-check that its fixed ;)

jkbest2 commented 5 years ago

I'm honestly not sure what's happening here. I suspect you're right and it's called somewhere in the eigenvalue code. Something changed in the standard libraries and CppAD lost the definitions of these functions, but that's as much as I've been able to figure out.

Until a new version of TMB (> v1.7.15) is released on CRAN, users who encounter this will want to update TMB to master using devtools::install_github("kaskr/admcomp/TMB"). Only Mac and Linux users should be affected right now. Windows users will typically be using RTools, which is distributed with gcc v4 (which is why you weren't able to replicate). This compiler (and gcc v5, per above) aren't affected, but gcc v6 and later are.

pdolder commented 5 years ago

Super, thanks John - to confirm that works fine now on my Linux machine.

Apologies for not picking up on all this earlier following the original issue, slipped by me...

jkbest2 commented 5 years ago

Great, thanks for the confirmation Paul! I'm just happy Kasper was able to work his magic so quickly.

Jim, I feel pretty confident that this is taken care of on Linux. Other checks you might consider:

sgaichas commented 5 years ago

I still had problems with macOS compilation for VAST 8.2 as described here, with workaround https://github.com/kaskr/adcomp/issues/297#issuecomment-518698659