title: Multiprocessing python program inside Docker
body: <p>I am trying to test multiprocessing for python inside a docker container but even, if the processes are created successfully (I have 8 CPUs and 8 processes are created), they always take only one physical CPU.
  Here is my code:</p>
  
  <pre><code>from sklearn.externals.joblib.parallel import Parallel, delayed
  import multiprocessing
  import pandas
  import numpy
  from scipy.stats import linregress
  import random
  import logging
  
  def applyParallel(dfGrouped, func):
      retLst = Parallel(n_jobs=multiprocessing.cpu_count())(delayed(func)(group) for name, group in dfGrouped)
      return pandas.concat(retLst)
  
  def compute_regression(df):
      result = {}
  
      (slope,intercept,rvalue,pvalue,stderr) = linregress(df.date,df.value)
      result["slope"] = [slope]
      result["intercept"] = [intercept]
  
      return pandas.DataFrame(result)
  
  if __name__ == '__main__':
      logging.basicConfig(level=logging.DEBUG,
                      format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
      logging.info("start")
      random_list = []
      for i in range(1,10000):
          for j in range(1,100):
              random_list.append({"id":i,"date":j,"value":random.random()})
  
      df = pandas.DataFrame(random_list)
  
      df = applyParallel(df.groupby('id'), compute_regression)
  
      logging.info("end")
  </code></pre>
  
  <p>I tried multiple docker options when I launch like --cpus or --cpuset but it is always using only 1 physical CPUs.
  Is it an issue in Docker, python, the OS?
  Docker version is 1.13.1</p>
  
  <p>The result of the <code>cpu_count()</code>:</p>
  
  <pre><code>&gt;&gt;&gt; import multiprocessing
  &gt;&gt;&gt; multiprocessing.cpu_count()
  8
  </code></pre>
  
  <p>During the run, here is a top. We can see the main process and the 8 child processes but I find the percentages weird.
  <a href="https://i.stack.imgur.com/WdW5r.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WdW5r.png" alt="top screenshot"></a></p>
  
  <p>And then, if I change to 4 processes, total amount of CPU used is always the same:
  <a href="https://i.stack.imgur.com/FRCFD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FRCFD.png" alt="top with 4 threads"></a></p>