macroevolution / bamm

A program for multimodel inference on speciation and trait evolution
GNU General Public License v2.0
33 stars 10 forks source link

threads not working on Ubuntu 14.04 LTS #132

Open tony-travis opened 10 years ago

tony-travis commented 10 years ago

Hi,

We're having problems running "bamm" under Bio-Linux 8 / Ubuntu 14.04 LTS. I've compiled the program from source (obtained from GitHub) but when I run it, "bamm" throws an exception. I've tried recompiling using this bug-fix for G++ and tried using "clang" instead, but the problem was not resolved - Any ideas?

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f27da2..10d19ca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ SET(BAMM_VERSION_DATE 2014-09-05)

 # Set compiler flags
 IF(NOT WIN32)
-  SET(CXX_LANGUAGE_FLAGS "-std=c++11")
+  SET(CXX_LANGUAGE_FLAGS "-Wl,--no-as-needed -std=c++11 -pthread")
   SET(CXX_DEBUG_FLAGS "-g")
   SET(CXX_WARNING_FLAGS "-Wall -Wextra")
   SET(CXX_OPTIMIZATION_FLAGS "-O3")

soi696@wildcat:~/Desktop/BAMM2$ bamm -c ControlFileAmoAspeciation.txt BAMM 2.2.0 (2014-09-05) Copyright (C) 2012-2014 Daniel Rabosky BAMM is distributed under the GNU General Public License. See http://bamm-project.org for more information.

Random seed: 1410445448

Model type: Speciation/Extinction

Reading tree from file . Tree contains 370 taxa.

Initial log-likelihood: -1285.74

Reading tree from file . Tree contains 370 taxa.

Initial log-likelihood: -1285.74

Reading tree from file . Tree contains 370 taxa.

Initial log-likelihood: -1285.74

Reading tree from file . Tree contains 370 taxa.

Initial log-likelihood: -1285.74

Running 4 chains for 80000000 generations.

terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread: Operation not permitted Aborted

redcurry commented 10 years ago

Hello,

We found this problem as well yesterday and I'm working on a solution. C++11 threads requires that the pthread library also be linked. The following will solve the problem, but I'm working on a more permanent solution:

SET(CMAKE_EXE_LINKER_FLAGS "-pthread")
tony-travis commented 10 years ago

Hi,

Just tried that too, and rebuilt "bamm" from scratch, but didn't WFM:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f27da2..ed40faa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,7 @@ IF(NOT WIN32)
   IF(APPLE AND (${CMAKE_CXX_COMPILER_ID} MATCHES Clang))
       SET(CXX_LANGUAGE_FLAGS "-std=c++11 -stdlib=libc++")
       SET(CXX_ARCHITECTURE_FLAGS "-arch x86_64")
-      SET(CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++")
+      SET(CMAKE_EXE_LINKER_FLAGS "-pthread")
   ENDIF(APPLE AND (${CMAKE_CXX_COMPILER_ID} MATCHES Clang))
 ELSE(NOT WIN32)
   SET(CXX_WARNING_FLAGS "/W4")
tony-travis commented 10 years ago

Sorry, closed by accident(!)

redcurry commented 10 years ago

Hello,

I've updated the CMake configuration file to find pthreads and link it. Please pull again from GitHub and let me know if it works now. Let me know which compiler you're using if it doesn't work. I tested it on g++ version 4.8.0. Thanks!

tony-travis commented 10 years ago

Hi,

Just re-cloned "bamm" from GitHub and rebuilt, but the same error as before - Not surprising, really, because I already tried the same edit manually ;-)

I'm using: root@wildcat:/usr/local/src/bioinformatics/BAMM/bamm/build# g++ --version g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2

Thanks for looking into the problem,

Tony.

redcurry commented 10 years ago

Let's see if it's a CMake problem or something else... In an empty "build" directory, compile bamm manually (without CMake):

g++ -DBAMM_VERSION=\"1.0\" -DBAMM_VERSION_DATE=\"1\" -DGIT_COMMIT_ID=\"0\" -pthread -std=c++11 -o bamm ../src/*.cpp

It should take less than a minute to compile and produce a single executable program named bamm. Try running it with data and let me know if that works.

Thanks.

tony-travis commented 10 years ago

OK, that works :-)

Thanks,

Tony.

redcurry commented 10 years ago

That's great. I'm not entirely sure, yet, why running CMake didn't work. I've made some changes to the CMakeLists.txt file. Do you mind pulling again, compiling using CMake, then running bamm?

Thanks.

tony-travis commented 10 years ago

Hi,

I did a new "git clone", but I got the same problem running "bamm" as before:

terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std::thread: Operation not permitted
Aborted

Bye,

Tony.

redcurry commented 10 years ago

I'm still not sure what the problem is, and I cannot replicate this error on my computer (also running GCC 4.8.2), but this link may provide an answer: http://stackoverflow.com/questions/20568235/using-c11-multithreading-in-shared-library-loaded-by-programm-without-thread-s (look at checked answer).

blackrim commented 10 years ago

I am getting the same problem here. Clean everything and same error terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread: Operation not permitted Aborted (core dumped) Tried manual pthread linking and all that. No luck This does work on the recent debian so this is an ubuntu problem.

tony-travis commented 10 years ago

On 02/10/14 01:09, Stephen Smith wrote:

I am getting the same problem here. Clean everything and same error terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread: Operation not permitted Aborted (core dumped) Tried manual pthread linking and all that. No luck This does work on the recent debian so this is an ubuntu problem.

Hi, Stephen.

Looks like a "cmake" problem, really, because the program compiles and runs properly without using "cmake". We are running the binary OK now.

Bye,

Tony.

Minke Informatics Limited, Registered in Scotland - Company No. SC419028 Registered Office: 3 Donview, Bridge of Alford AB33 8QJ, Scotland (UK) tel. +44(0)19755 63548 http://minke-informatics.co.uk mob. +44(0)7985 078324 mailto:tony.travis@minke-informatics.co.uk

blackrim commented 10 years ago

Thanks Tony, you are correct that worked fine.

paternogbc commented 9 years ago

Hi I am running bamm in Ubuntu 14 LTS and I am facing the same problem. I tried the solution proposed: " g++ -DBAMM_VERSION=\"1.0\" -DBAMM_VERSION_DATE=\"1\" -DGIT_COMMIT_ID=\"0\" -pthread -std=c++11 -o bamm ../src/*.cpp"

and it works, however it seems to take much longer when compared with an similar windows computer. Any suggestion?

Thanks in advance, Gustavo

rhr commented 9 years ago

cmake creates a file CMakeFiles/bamm.dir/link.txt in the build directory that contains the final linking command. Change '-lpthread' to '-pthread' in this file and re-run the command to build a working binary. This worked for me on Ubuntu 14.04.

mkandziora commented 8 years ago

I just compiled the version 2.5 on ubuntu 14.04 and run into this issue: terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread: Operation not permitted

the above mentioned solution of rhr solved the issue.

loloNC commented 8 years ago

Hi everyone,

I am very novice with the use of linux. I work since a week on ubuntu 14.04. I installed bamm and had the same problem when running an analysis (with the same error message as above : terminate called after throwing an instance of 'std::system_error', what(): Enable multithreading to use std::thread: Operation not permitted, Aborted)

I attempted to use the solution proposed by rhr. But apparently I haven't done properly the manipulation under the shell, because : 1) bamm still doesn't work (I get the same error message when running analyses) 2) when I re-open the file CMakeFiles/bamm.dir/link.txt the '-lpthread' reappeared even if I changed it previously by '-pthread' (just before running the cmake .. command)

Could you explain me step by step what I have to do in the shell to solve this problem.

Thank you in advances

Bisaloo commented 8 years ago

The solution proposed by rhr works for me as well.

@loloNC : you are not supposed to re-run cmake ... Edit the file, then run cmake -j and it should work.

paternogbc commented 8 years ago

Just instaled BAMM v2.5 and it is working very nice on Ubuntu 16.04.

Instaled from source with the following commands:

git clone https://github.com/macroevolution/bamm.git mkdir build cd build cmake .. make -j sudo make install

sjackman commented 7 years ago

@tmozgach resolved this issue with Linuxbrew and Homebrew/science in PR https://github.com/Homebrew/homebrew-science/pull/5832 If you're encountering this issue, you may wish to consider installing bamm using Linuxbrew See http://linuxbrew.sh for Linuxbrew installation instructions then run

brew install homebrew/science/bamm