Issue with shm.dll file

Koustubha_Nagaraj: <p>How can i fix this error?</p>
<p>Traceback (most recent call last):<br>
File “d:\koust\Documents\aiiiii\app.py”, line 2, in <br>
from transformers import pipeline<br>
File “C:\Users\koust\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\transformers_init_.py”, line 26, in <br>
from . import dependency_versions_check<br>
File “C:\Users\koust\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\transformers\dependency_versions_check.py”, line 16, in <br>
from .utils.versions import require_version, require_version_core<br>
File “C:\Users\koust\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\transformers\utils_init_.py”, line 33, in <br>
from .generic import (<br>
File “C:\Users\koust\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\transformers\utils\generic.py”, line 465, in <br>
import torch.utils._pytree as <em>torch_pytree<br>
File "C:\Users\koust\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\torch_init</em>.py", line 141, in <br>
raise err<br>
OSError: [WinError 126] The specified module could not be found. Error loading “C:\Users\koust\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\torch\lib\shm.dll” or one of its dependencies.</p>

Nikitha_Krishnan: <p>Did you solved it??</p>
<p>Same Issue here. In python 3.12.</p>

048_Elham_Bhuiyan: <p>facing the same issue here, did you solve it?</p>

lerrana: <p>A fix was published by the pytorch team 2 days ago:</p>
<aside class="onebox githubcommit" data-onebox-src="https://github.com/pytorch/pytorch/commit/fdfef759a676ee7a853872e347537bc1e4b51390">
  <header class="source">

      <a href="https://github.com/pytorch/pytorch/commit/fdfef759a676ee7a853872e347537bc1e4b51390" target="_blank" rel="noopener nofollow ugc">github.com/pytorch/pytorch</a>
  </header>

  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Commit">
    <svg width="60" height="60" class="github-icon" viewBox="0 0 14 16" aria-hidden="true"><path fill-rule="evenodd" d="M10.86 7c-.45-1.72-2-3-3.86-3-1.86 0-3.41 1.28-3.86 3H0v2h3.14c.45 1.72 2 3 3.86 3 1.86 0 3.41-1.28 3.86-3H14V7h-3.14zM7 10.2c-1.22 0-2.2-.98-2.2-2.2 0-1.22.98-2.2 2.2-2.2 1.22 0 2.2.98 2.2 2.2 0 1.22-.98 2.2-2.2 2.2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/pytorch/pytorch/commit/fdfef759a676ee7a853872e347537bc1e4b51390" target="_blank" rel="noopener nofollow ugc">Add userbase library dir to windows dll search path (#125684)</a>
    </h4>

    <div class="github-info">
      <div class="date">
        committed <span class="discourse-local-date" data-format="ll" data-date="2024-05-07" data-time="20:43:40" data-timezone="UTC">08:43PM - 07 May 24 UTC</span>
      </div>

      <div class="user">
        <a href="https://github.com/atalman" target="_blank" rel="noopener nofollow ugc">
          <img alt="atalman" src="https://avatars.githubusercontent.com/u/7563158?v=4" class="onebox-avatar-inline" width="20" height="20">
          atalman
        </a>
      </div>

      <div class="lines" title="changed 1 files with 3 additions and 1 deletions">
        <a href="https://github.com/pytorch/pytorch/commit/fdfef759a676ee7a853872e347537bc1e4b51390" target="_blank" rel="noopener nofollow ugc">
          <span class="added">+3</span>
          <span class="removed">-1</span>
        </a>
      </div>
    </div>
  </div>
</div>

  <div class="github-row">
    <p class="github-body-container">Fixes https://github.com/pytorch/pytorch/issues/125109 which is a regression int<span class="show-more-container"><a href="https://github.com/pytorch/pytorch/commit/fdfef759a676ee7a853872e347537bc1e4b51390" target="_blank" rel="noopener nofollow ugc" class="show-more">…</a></span><span class="excerpt hidden">roduced by https://github.com/pytorch/builder/pull/1467 that adds dynamic dependency to mkl, which if installed in the user-dir is placed into `sysconfig.sysconfig.get_config_var("userbase") / "Library" / "bin"`

Fix this one, but adding `userbase` folder to the DLL search path

Testing before this fix:
```
Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import torch
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "C:\Users\Administrator\AppData\Roaming\Python\Python312\site-packages\torch\__init__.py", line 141, in &lt;module&gt;
    raise err
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\Administrator\AppData\Roaming\Python\Python312\site-packages\torch\lib\shm.dll" or one of its dependencies.
&gt;&gt;&gt; exit()
```

After:
```
c:\Program Files\Python312&gt;python
Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import torch
&gt;&gt;&gt; exit()
```
Co-authored-by: Nikita Shulga &lt;2453524+malfet@users.noreply.github.com&gt;
Pull Request resolved: https://github.com/pytorch/pytorch/pull/125684
Approved by: https://github.com/malfet</span></p>
  </div>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>I tried to replace the file but it didn’t work, I had to change the code directly in the file, like in the commit.</p>