title: XGBoost training with n_jobs = -1 not using all cores
body: <p>I'm having problems using all cores on computer for training and cross-validation of XGBoost model.</p>
  
  <p>Data:</p>
  
  <pre><code>data_dmatrix = xgb.DMatrix(data=X,label=y, nthread=-1)
  dtrain = xgb.DMatrix(X_train, label=y_train, nthread=-1)
  dtest = xgb.DMatrix(X_test, label=y_test, nthread=-1)
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>xg_model = XGBRegressor(objective='reg:linear', colsample_bytree= 0.3, learning_rate = 0.2,
                           max_depth = 5, alpha = 10, n_estimators = 100, subsample=0.4, booster = 'gbtree', n_jobs=-1)
  </code></pre>
  
  <p>and than if I do model training with:</p>
  
  <pre><code>xgb.train(
      xg_model.get_xgb_params(),
      dtrain,
      num_boost_round=500,
      evals=[(dtest, "Test")],
      early_stopping_rounds=200)
  </code></pre>
  
  <p>It works ok but it uses only 1 thread to run xgboost. 
  Processor is on 25%. It ignores  <code>n_jobs=-1</code></p>
  
  <p>But if I do cross-validation with scikit-learn implementation:</p>
  
  <pre><code>scores = cross_val_score(xg_model, X, y, cv=kfold, n_jobs=-1)
  </code></pre>
  
  <p>than it uses all cores.
  How can I force <code>xgb.train</code> and <code>xgb.cv</code> to use all cores?</p>