XGBoost parallelization issue on macOS High Sierra
up vote
0
down vote
favorite
I am using Anaconda environment on macOS High Sierra and could not run XGBoost with 8 thread even though I set the nthread parameter to 8.
The python code is like this. When I run it, I monitor the execution by looking at htop. There is only one process which is 100%.
clf = xgb.XGBClassifier(
**xgb_params,
n_estimators=1000,
nthread=8
)
Then I searched on the internet and found this link. Some people refer this one and I followed it.
https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_XGBoost_on_Mac_OSX?lang=en
➜ ~ brew install gcc --without-multilib
Warning: gcc 8.2.0 is already installed and up-to-date
To reinstall 8.2.0, run `brew reinstall gcc`
After seeing this info, I added the following lines to my xgboost config
export CC = gcc-8
export CXX = g++-8
When the build is done. I tried it again and nothing changed.
So, I kept searching the solution. I found this page.
https://clang-omp.github.io/
Then I ran the following line.
brew install llvm
And I tried to do the example in that site. I created a file, which is called hello.c, and put the following code inside.
#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %dn", omp_get_thread_num(),
omp_get_num_threads());
}
Then I tried to compile it as mentioned.
clang -fopenmp hello.c -o hello
It worked! I also tried gcc-8 as follows.
gcc-8 -fopenmp hello.c -o hello
It also worked. So, this is the output when I run ./hello
➜ ~ ./hello
Hello from thread 4, nthreads 8
Hello from thread 7, nthreads 8
Hello from thread 2, nthreads 8
Hello from thread 1, nthreads 8
Hello from thread 6, nthreads 8
Hello from thread 3, nthreads 8
Hello from thread 0, nthreads 8
Hello from thread 5, nthreads 8
So, I added gcc-8 in xgboost config file and gcc-8 is able to run in parallel with -fopenmp option as you can see. However, XGBoost does not run in parallel even though I compile it with this setting and set the nthread parameter to 8.
Is there any idea that I can try more?
Edit 1: I tried more complex code to ensure parellalization works. I tried this code. The output shows 8 thread work. I also see it by typing htop.
➜ ~ clang -fopenmp OpenMP.c -o OpenMP
➜ ~ ./OpenMP
---- Serial
---- Serial done in 37.058571 seconds.
---- Parallel
---- Parallel done in 9.674641 seconds.
---- Check
Passed
Edit 2: I installed gcc-7 and did same process. It did not work either.
python macos openmp xgboost macos-high-sierra
add a comment |
up vote
0
down vote
favorite
I am using Anaconda environment on macOS High Sierra and could not run XGBoost with 8 thread even though I set the nthread parameter to 8.
The python code is like this. When I run it, I monitor the execution by looking at htop. There is only one process which is 100%.
clf = xgb.XGBClassifier(
**xgb_params,
n_estimators=1000,
nthread=8
)
Then I searched on the internet and found this link. Some people refer this one and I followed it.
https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_XGBoost_on_Mac_OSX?lang=en
➜ ~ brew install gcc --without-multilib
Warning: gcc 8.2.0 is already installed and up-to-date
To reinstall 8.2.0, run `brew reinstall gcc`
After seeing this info, I added the following lines to my xgboost config
export CC = gcc-8
export CXX = g++-8
When the build is done. I tried it again and nothing changed.
So, I kept searching the solution. I found this page.
https://clang-omp.github.io/
Then I ran the following line.
brew install llvm
And I tried to do the example in that site. I created a file, which is called hello.c, and put the following code inside.
#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %dn", omp_get_thread_num(),
omp_get_num_threads());
}
Then I tried to compile it as mentioned.
clang -fopenmp hello.c -o hello
It worked! I also tried gcc-8 as follows.
gcc-8 -fopenmp hello.c -o hello
It also worked. So, this is the output when I run ./hello
➜ ~ ./hello
Hello from thread 4, nthreads 8
Hello from thread 7, nthreads 8
Hello from thread 2, nthreads 8
Hello from thread 1, nthreads 8
Hello from thread 6, nthreads 8
Hello from thread 3, nthreads 8
Hello from thread 0, nthreads 8
Hello from thread 5, nthreads 8
So, I added gcc-8 in xgboost config file and gcc-8 is able to run in parallel with -fopenmp option as you can see. However, XGBoost does not run in parallel even though I compile it with this setting and set the nthread parameter to 8.
Is there any idea that I can try more?
Edit 1: I tried more complex code to ensure parellalization works. I tried this code. The output shows 8 thread work. I also see it by typing htop.
➜ ~ clang -fopenmp OpenMP.c -o OpenMP
➜ ~ ./OpenMP
---- Serial
---- Serial done in 37.058571 seconds.
---- Parallel
---- Parallel done in 9.674641 seconds.
---- Check
Passed
Edit 2: I installed gcc-7 and did same process. It did not work either.
python macos openmp xgboost macos-high-sierra
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using Anaconda environment on macOS High Sierra and could not run XGBoost with 8 thread even though I set the nthread parameter to 8.
The python code is like this. When I run it, I monitor the execution by looking at htop. There is only one process which is 100%.
clf = xgb.XGBClassifier(
**xgb_params,
n_estimators=1000,
nthread=8
)
Then I searched on the internet and found this link. Some people refer this one and I followed it.
https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_XGBoost_on_Mac_OSX?lang=en
➜ ~ brew install gcc --without-multilib
Warning: gcc 8.2.0 is already installed and up-to-date
To reinstall 8.2.0, run `brew reinstall gcc`
After seeing this info, I added the following lines to my xgboost config
export CC = gcc-8
export CXX = g++-8
When the build is done. I tried it again and nothing changed.
So, I kept searching the solution. I found this page.
https://clang-omp.github.io/
Then I ran the following line.
brew install llvm
And I tried to do the example in that site. I created a file, which is called hello.c, and put the following code inside.
#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %dn", omp_get_thread_num(),
omp_get_num_threads());
}
Then I tried to compile it as mentioned.
clang -fopenmp hello.c -o hello
It worked! I also tried gcc-8 as follows.
gcc-8 -fopenmp hello.c -o hello
It also worked. So, this is the output when I run ./hello
➜ ~ ./hello
Hello from thread 4, nthreads 8
Hello from thread 7, nthreads 8
Hello from thread 2, nthreads 8
Hello from thread 1, nthreads 8
Hello from thread 6, nthreads 8
Hello from thread 3, nthreads 8
Hello from thread 0, nthreads 8
Hello from thread 5, nthreads 8
So, I added gcc-8 in xgboost config file and gcc-8 is able to run in parallel with -fopenmp option as you can see. However, XGBoost does not run in parallel even though I compile it with this setting and set the nthread parameter to 8.
Is there any idea that I can try more?
Edit 1: I tried more complex code to ensure parellalization works. I tried this code. The output shows 8 thread work. I also see it by typing htop.
➜ ~ clang -fopenmp OpenMP.c -o OpenMP
➜ ~ ./OpenMP
---- Serial
---- Serial done in 37.058571 seconds.
---- Parallel
---- Parallel done in 9.674641 seconds.
---- Check
Passed
Edit 2: I installed gcc-7 and did same process. It did not work either.
python macos openmp xgboost macos-high-sierra
I am using Anaconda environment on macOS High Sierra and could not run XGBoost with 8 thread even though I set the nthread parameter to 8.
The python code is like this. When I run it, I monitor the execution by looking at htop. There is only one process which is 100%.
clf = xgb.XGBClassifier(
**xgb_params,
n_estimators=1000,
nthread=8
)
Then I searched on the internet and found this link. Some people refer this one and I followed it.
https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_XGBoost_on_Mac_OSX?lang=en
➜ ~ brew install gcc --without-multilib
Warning: gcc 8.2.0 is already installed and up-to-date
To reinstall 8.2.0, run `brew reinstall gcc`
After seeing this info, I added the following lines to my xgboost config
export CC = gcc-8
export CXX = g++-8
When the build is done. I tried it again and nothing changed.
So, I kept searching the solution. I found this page.
https://clang-omp.github.io/
Then I ran the following line.
brew install llvm
And I tried to do the example in that site. I created a file, which is called hello.c, and put the following code inside.
#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %dn", omp_get_thread_num(),
omp_get_num_threads());
}
Then I tried to compile it as mentioned.
clang -fopenmp hello.c -o hello
It worked! I also tried gcc-8 as follows.
gcc-8 -fopenmp hello.c -o hello
It also worked. So, this is the output when I run ./hello
➜ ~ ./hello
Hello from thread 4, nthreads 8
Hello from thread 7, nthreads 8
Hello from thread 2, nthreads 8
Hello from thread 1, nthreads 8
Hello from thread 6, nthreads 8
Hello from thread 3, nthreads 8
Hello from thread 0, nthreads 8
Hello from thread 5, nthreads 8
So, I added gcc-8 in xgboost config file and gcc-8 is able to run in parallel with -fopenmp option as you can see. However, XGBoost does not run in parallel even though I compile it with this setting and set the nthread parameter to 8.
Is there any idea that I can try more?
Edit 1: I tried more complex code to ensure parellalization works. I tried this code. The output shows 8 thread work. I also see it by typing htop.
➜ ~ clang -fopenmp OpenMP.c -o OpenMP
➜ ~ ./OpenMP
---- Serial
---- Serial done in 37.058571 seconds.
---- Parallel
---- Parallel done in 9.674641 seconds.
---- Check
Passed
Edit 2: I installed gcc-7 and did same process. It did not work either.
python macos openmp xgboost macos-high-sierra
python macos openmp xgboost macos-high-sierra
edited Nov 8 at 15:58
asked Nov 8 at 10:07
Ugurcan Lacin
212
212
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205474%2fxgboost-parallelization-issue-on-macos-high-sierra%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password