Ran into this issue while executing

sparshgarg23: <p>Hi,<br>
I recently came across this post  mentioned in the below link<br>
<a href="https://towardsdatascience.com/the-one-pytorch-trick-which-you-should-know-2d5e9c1da2ca" class="onebox" target="_blank" rel="noopener nofollow ugc">https://towardsdatascience.com/the-one-pytorch-trick-which-you-should-know-2d5e9c1da2ca</a></p>
<p>When I ran the code mentioned in the link,I ran into the following error<br>
OMP: Error <span class="hashtag">#15:</span> Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.<br>
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see <a href="http://www.intel.com/software/products/support/" rel="noopener nofollow ugc">http://www.intel.com/software/products/support/</a>.<br>
[SpyderKernelApp] WARNING | No such comm: 226297d71da911eb95ceaced5c5490c5<br>
Notice that when the following lines were added<br>
import os<br>
<span class="hashtag">#os</span>.environ[“KMP_DUPLICATE_LIB_OK”]=“TRUE”<br>
the issue would disappear.Any ideas why this is happening and what can be done to get around this issue?<br>
Pytorch was installed using  the command<br>
pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio===0.7.0 -f <a href="https://download.pytorch.org/whl/torch_stable.html" rel="noopener nofollow ugc">https://download.pytorch.org/whl/torch_stable.html</a><br>
System config Windows 10 CPU intel i5<br>
Python 3.8.3</p>

Arijit_Ghosh: <p>Hye,<br>
I also ran in the same trouble.<br>
Found any strong solution?</p>

sparshgarg23: <p>you can refer to this<br>
since i prefer quick fixes,i went with</p>
<pre><code class="lang-auto">import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
</code></pre>
<p>but the correct solution is to create a seperate environment,and in that you must install all your packages</p><aside class="onebox stackexchange" data-onebox-src="https://stackoverflow.com/questions/20554074/sklearn-omp-error-15-when-fitting-models">
  <header class="source">

      <a href="https://stackoverflow.com/questions/20554074/sklearn-omp-error-15-when-fitting-models" target="_blank" rel="noopener nofollow ugc">stackoverflow.com</a>
  </header>

  <article class="onebox-body">
      <a href="https://stackoverflow.com/users/2423116/adj" target="_blank" rel="noopener nofollow ugc">
    <img alt="ADJ" src="https://www.gravatar.com/avatar/8047e96df3264a4cabc812b4da38577e?s=128&amp;d=identicon&amp;r=PG" class="thumbnail onebox-avatar" width="128" height="128">
  </a>

<h4>
  <a href="https://stackoverflow.com/questions/20554074/sklearn-omp-error-15-when-fitting-models" target="_blank" rel="noopener nofollow ugc">sklearn OMP: Error #15 when fitting models</a>
</h4>

<div class="tags">
  <strong>python, scikit-learn, enthought, canopy</strong>
</div>

<div class="date">
  asked by
  
  <a href="https://stackoverflow.com/users/2423116/adj" target="_blank" rel="noopener nofollow ugc">
    ADJ
  </a>
  on <a href="https://stackoverflow.com/questions/20554074/sklearn-omp-error-15-when-fitting-models" target="_blank" rel="noopener nofollow ugc">08:56PM - 12 Dec 13 UTC</a>
</div>

  </article>

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

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


Arijit_Ghosh: <p>Hye!<br>
I did that, it was fixed for the time being.</p>
<p>But I didn’t like the aesthetic of it. So, after going through a bit, I just reinstalled pytorch but with a downgraded version (1.7.1). No issues after that. Some pointy bugs I guess with Python version 3.8 and above with Pytorch version 1.9.</p>