title: Pyinstaller stuck when including tensorflow-cpu and tensorflow-directml-plugin
body: <p>I am trying to create a single executable file with pyinstaller, I have installed in my environment <code>tensorflow-cpu==2.9</code> and <code>tensorflow-directml-plugin==0.0.1.dev220621</code> I used this because I have an intel GPU where I want to run a tensorflow model. I found this solution in <a href="https://docs.microsoft.com/en-us/windows/ai/directml/gpu-tensorflow-plugin" rel="nofollow noreferrer">here</a>. When I run the script in visual studio code it runs without a problem and the model runs in the GPU, but when I try to make it exe file with pyinstaller it gets stuck in this message:</p>
  <pre><code>F tensorflow/c/experimental/stream_executor/stream_executor.cc:808] Non-OK-status: stream_executor::MultiPlatformManager::RegisterPlatform( std::move(cplatform)) statum( std::move(cplatform)) status: INTERNAL: platform is already registered with name: &quot;DML&quot;
  </code></pre>
  <p>Also before that message, it spams a lot this:</p>
  <pre><code>    2022-07-20 15:01:23.929010: I tensorflow/c/logging.cc:34] Successfully opened dynamic library dxgi.dll
  2022-07-20 15:01:23.930664: I tensorflow/c/logging.cc:34] Successfully opened dynamic library d3d12.dll
  2022-07-20 15:01:23.993556: I tensorflow/c/logging.cc:34] DirectML device enumeration: found 1 compatible adapters.
  2022-07-20 15:01:26.072697: I tensorflow/c/logging.cc:34] Successfully opened dynamic library C:\Users\xx\Documents\DMLEnvironment\lib\site-packages\tensorflow-plugins/directml/directml.0de2b4431c6572ee74152a7ee0cd3fb1534e4a95.dll
  </code></pre>
  <p>I tried uninstalling tensorflow-cpu and installing the normal tensorflow, but then the script did not run. I think there is a conflict between tensorflow-cpu and tensorflow-directml-plugin but I find it weird that it works if I run the script directly from visual studio code.</p>
  <p>Any idea of why this could be happening?</p>
  <p>P.S. I am using virtual environment with python 3.8 and pyinstaller 5.2</p>
  <p><strong>Update:</strong></p>
  <p>I managed to make it work with Pyinstaller 4.10 and there is a problem:</p>
  <pre><code>  File &quot;PyInstaller\loader\pyimod03_importers.py&quot;, line 495, in exec_module
    File &quot;tensorflow\__init__.py&quot;, line 37, in &lt;module&gt;
    File &quot;PyInstaller\loader\pyimod03_importers.py&quot;, line 495, in exec_module
    File &quot;tensorflow\python\__init__.py&quot;, line 37, in &lt;module&gt;
    File &quot;PyInstaller\loader\pyimod03_importers.py&quot;, line 495, in exec_module
    File &quot;tensorflow\python\eager\context.py&quot;, line 33, in &lt;module&gt;
    File &quot;PyInstaller\loader\pyimod03_importers.py&quot;, line 495, in exec_module
    File &quot;tensorflow\python\pywrap_tfe.py&quot;, line 25, in &lt;module&gt;
  ImportError: DLL load failed while importing _pywrap_tfe: Die angegebene Prozedur wurde nicht gefunden.
  [13284] Failed to execute script due to unhandled exception!
  </code></pre>
  <p>I managed to solve this problem by adding the .pyd file in my .spec file in the <em>data</em> option like:</p>
  <pre><code>datas=[
        (&quot;DMLEnvironment/Lib/site-packages/tensorflow/python/_pywrap_tfe.pyd&quot;, &quot;tensorflow/python&quot;),
               ],
  </code></pre>
  <p>but the exe file (onefile) does not run the tensorflow-directml-plugin because my model is still running in the CPU and not the GPU. I tried to put tensorflow-directml-plugin package as a hidden import in the .spec file but this didn't work.</p>