Problem with importing torch

When i importing the torch i get an error below i also try to re-install :

Cell In[1], line 1
----> 1 import torch

File C:\Python37\Lib\site-packages\torch_init_.py:141
139 err = ctypes.WinError(ctypes.get_last_error())
140 err.strerror += f’ Error loading “{dll}” or one of its dependencies.’
→ 141 raise err
143 kernel32.SetErrorMode(prev_error_mode)
146 def _preload_cuda_deps(lib_folder, lib_name):

OSError: [WinError 126] The specified module could not be found. Error loading “C:\Python37\Lib\site-packages\torch\lib\caffe2_nvrtc.dll” or one of its dependencies.

please help me solve this .

Hi @Jenil_g , it seems you are facing a dependency issue in your CUDA environment. By the other side, it seems you are trying to run a Python code in your home environment, which is not a good approach.
Instead, using Conda you can create your particular environment that will not affect your home environment. This is the most used solutions when dealing with models. So, you can just try

Blockquote
conda create -n <my_env> python==3.10

This way, you can better control your environment, minimizing issues like the one you are pointing out.
Keep learning!