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.










share|improve this question




























    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.










    share|improve this question


























      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.










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 8 at 15:58

























      asked Nov 8 at 10:07









      Ugurcan Lacin

      212




      212





























          active

          oldest

          votes











          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%2f53205474%2fxgboost-parallelization-issue-on-macos-high-sierra%23new-answer', 'question_page');
          }
          );

          Post as a guest





































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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




















































































          Popular posts from this blog

          Landwehr

          Reims

          Schenkenzell