Module not found 'torch'

Yana_G: <p>Hi,</p>
<p>I’ve installed the latest version of pytorch (1.12.1) with cuda 11.3 using the following command in a new conda environment:<br>
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch</p>
<p>but when i try to import torch: “import torch” and running it i’m getting Module not found error: “torch”</p>
<p>I’m running on Windows 10, and i’ve tried using python=3.8 and python=3.9 and python=3.7 and still getting this error.</p>
<p>Also i made sure that i have cuda 11.3 installed using nvcc --version<br>
nvcc: NVIDIA (R) Cuda compiler driver<br>
Copyright (c) 2005-2021 NVIDIA Corporation<br>
Built on Sun_Mar_21_19:24:09_Pacific_Daylight_Time_2021<br>
Cuda compilation tools, release 11.3, V11.3.58<br>
Build cuda_11.3.r11.3/compiler.29745058_0</p>
<p>Any idea what could be the problem and how to resolve it?</p>

azhanmohammed: <aside class="quote no-group" data-username="Yana_G" data-post="1" data-topic="161263">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/y/e9a140/48.png" class="avatar"> Yana_G:</div>
<blockquote>
<p>but when i try to import torch: “import torch” and running it i’m getting Module not found error: “torch”</p>
</blockquote>
</aside>
<p>Are you sure that you are activating the correct environment when importing torch? Just check if that is the issue.</p>

Yana_G: <p>yes, unfortunately i activated the correct environment. i try it from ipython on the console and it doesn’t work <img src="https://discuss.pytorch.org/images/emoji/apple/frowning.png?v=12" title=":frowning:" class="emoji" alt=":frowning:" loading="lazy" width="20" height="20"></p>

Yana_G: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/b/d/bd74b3613ee75b830f192f770b3b3f5ff3fb332a.png" data-download-href="https://discuss.pytorch.org/uploads/default/bd74b3613ee75b830f192f770b3b3f5ff3fb332a" title="Capture"><img src="https://discuss.pytorch.org/uploads/default/original/3X/b/d/bd74b3613ee75b830f192f770b3b3f5ff3fb332a.png" alt="Capture" data-base62-sha1="r20gRDhBRk6xn2rvdE4tm85Iigi" width="690" height="424" data-dominant-color="143B45"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Capture</span><span class="informations">1253×771 40.3 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>I even tried to install it using the pip installation from the official site and still the same problem</p>
<p>maybe it happens because i still have cuda 10.2 installed but in the environment variables in CUDA_PATH i have cuda 11.3</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/a/9/a9bc92b963141dfce5e0a5ff64d2cd796ebbfe65.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/a9bc92b963141dfce5e0a5ff64d2cd796ebbfe65" title="Capture1.PNG"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/a/9/a9bc92b963141dfce5e0a5ff64d2cd796ebbfe65_2_644x500.jpeg" alt="Capture1.PNG" data-base62-sha1="odyHVQGW1MVh2PO1HwRI9b3sznn" width="644" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/a/9/a9bc92b963141dfce5e0a5ff64d2cd796ebbfe65_2_644x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/a/9/a9bc92b963141dfce5e0a5ff64d2cd796ebbfe65_2_966x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/a/9/a9bc92b963141dfce5e0a5ff64d2cd796ebbfe65.jpeg 2x" data-dominant-color="E6EAEB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Capture1.PNG</span><span class="informations">1198×929 112 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<img src="https://discuss.pytorch.org/uploads/default/original/3X/2/d/2dddcea76ff2090f8687e402e16619403c93b830.png" alt="Capture2" data-base62-sha1="6xKHLQskwGVOTjZFFpiuZy4mvle" width="593" height="189"></p>

azhanmohammed: <p>The issue happens because your environment is not activated on the IPython kernel. You can add the environment to IPython terminal using <a href="http://echrislynch.com/2019/02/01/adding-an-environment-to-jupyter-notebooks/" rel="noopener nofollow ugc">this</a>. Should do the work.</p>