title: How to avoid loading a parent module in a forked process with Pythons multiprocessing
body: <p>When you create a <code>Pool</code> of processes using Python's <code>multiprocessing</code>, those processes will fork and globals in the parent process will show up in the child processes, noted in this question below:</p>
  
  <p><a href="https://stackoverflow.com/questions/25477470/how-can-i-restrict-the-scope-of-a-multiprocessing-process">How can I restrict the scope of a multiprocessing process?</a></p>
  
  <p>This appears to include imported modules. That's a problem for modules that have side effects in <code>__init__</code>. Tensorflow is one such module, as soon as it's imported it tries to allocate memory to the GPU. This causes the sub process to crash because the parent already took that action.</p>
  
  <p>Is there a good way to avoid the tensorflow module loading in the forked process?</p>
  
  <p>Python 2.7 on Ubuntu (posix)</p>