akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
Problem: pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-url https://download.pytorch.org/whl/cu118

username: bunny_ville
cooked: <p>Recently I needed to deploy the cuda11.8 related configuration files on the anaconda virtual environment in vscode.But when I input this command</p>
<pre><code class="lang-auto">pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-url https://download.pytorch.org/whl/cu118
</code></pre>
<p>It cannot download packages related to CUDA automatically from that website, including:<br>
<img src="https://discuss.pytorch.org/uploads/default/original/3X/8/d/8d52bd962cc0b3a44ce8d2f69bcdcb95c055c4a8.png" alt="image" data-base62-sha1="kacAQ4N1Vpd4ZCxDID6ZhHc8LW0" width="369" height="339"><br>
I’ve tried numerous devices, including servers and laptops running Ubuntu 22.04, some of which can download all configurations properly, while others cannot. I’d like to understand how to resolve this issue.This is all the code instructions I entered in the vscode console：</p>
<pre><code class="lang-auto">conda create -n &lt;myenv&gt; python=3.10.13
conda activate &lt;myenv&gt;
conda install nvidia/label/cuda-11.8.0::cuda-toolkit
pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-url https://download.pytorch.org/whl/cu118
conda install -c "nvidia/label/cuda-11.8.0" cuda-nvcc
conda install packaging
</code></pre>

username: bunny_ville
cooked: <p>this problem had been solved!!! you only need to follow these steps:</p>
<ul>
<li>check your pip version</li>
</ul>
<pre><code class="lang-auto">pip --version
</code></pre>
<blockquote>
<p>output → pip 23.3.1 from /root/miniconda3/lib/python3.12/site-packages/pip (python 3.12)</p>
</blockquote>
<ul>
<li>if your pip version is higher than 22.0.2, please downgrade the version</li>
</ul>
<pre><code class="lang-auto">python -m pip install pip==20.0.2
</code></pre>
<ul>
<li>enter the following command:</li>
</ul>
<pre><code class="lang-auto">pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
</code></pre>
<p>Note: Before running this command, ensure that torch is not installed in the virtual environment; otherwise, CUDA-related dependencies cannot be installed<br>
Unknown: How do I install cuda-runtime and other packages independently in anaconda without installing torch</p>
Dataframe kindo-of-object in pytorch

username: Ghostv
cooked: <p>Hi!</p>
<p>This is a 100% open question, so, any idea would be more than welcome! I’m trying to emulate a similar structure to a pandas dataframe in pytorch (a data table, with named columns with different dtypes, with the possibility to run simple methods on them like sorting, etc), but after many days of searching, i haven’t been able to figure out if there is something similar or if can be achieved somehow with normal tensors.</p>
<p>I found something called torcharrow which seems to point in that direction, but the project is apparently abandoned and didn’t get past python 3.9.</p>
<p>Is there some pytorch object/project with this approach/functionality?</p>
<p>Thanks in advance!!</p>

username: JuanFMontesinos
cooked: <p>There is cuDF that is GPU powered and a drop-in-replace of pandas.<br>
I guess that’s the most similar thing, but actually your goal is pretty hard <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>

username: Ghostv
cooked: <p>Yeah, i know, but cudf (rapids) is also not yet available for python 3.12.</p>
<p>My work dev projects are basically in numpy+pandas (mostly), so, my goal was to see if i could basically replace both of them with pytorch.</p>
<p>I found that project i mentioned in my first post, torcharrow, which was literally that, pandas in pytorch, i was just hoping that there was another similar object/class in the pytorch ecosystem <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>Thanks anyway!</p>
Using pytorch instead of matlab

username: saleh1
cooked: <p>i will use pytorch instead of matlab so i wanted to ask you what are the equivalent of the Levenberg–Marquardt, Bayesian regularization, and scaled conjugate gradient training algorithms in pytorch instead of matlab are they under the same names in pytorch ?</p>
<p>i will use these on a research study but don’t have the money for matlab</p>

username: KFrank
cooked: <p>Hi Saleh!</p>
<aside class="quote no-group" data-username="saleh1" data-post="1" data-topic="202664" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/saleh1/48/69024_2.png" class="avatar"> saleh1:</div>
<blockquote>
<p>don’t have the money for matlab</p>
</blockquote>
</aside>
<p>Consider using <a href="https://octave.org/" rel="noopener nofollow ugc">GNU Octave,</a> an open-source scientific-programming package that<br>
is “largely compatible with Matlab.”</p>
<p>(I am not aware of pytorch having any of the algorithms you mentioned built in.)</p>
<p>Best.</p>
<p>K. Frank</p>

username: Ghostv
cooked: <p>I was gonna say the same. Octave is literally “open source matlab”, it’s a language 99.99% identical to matlab’s language and the differences are basically  ‘less-strict’ things in octave.</p>
Lightning use and applications

username: Mike_Schaid
cooked: <p>I’m just generally curious how many people actively use, continue to use, or have stopped using PyTorch Lightning? I like the idea from an implementation perspective, but forcing a team to learn another framework always feels like friction.  The fine grain control with pytorch is what I want, but the collaboration and ease of experimentation with lighting is useful. Please share your thoughts, pros and cons and if you use lighting for experimentation, or prefer to build your own tools. Thanks!</p>
Deciding number of layers for SVHN dataset

username: Geetanjli_sharma
cooked: <p>I am running FL setup on SVHN dataset and having error :RuntimeError: mat1 and mat2 shapes cannot be multiplied (32768x3 and 20480*2048<br>
)<br>
My sample input shape is : (32, 32, 3) with 10 outputs and I am running it on model:</p>
<p>class Net(nn.Module):<br>
def <strong>init</strong>(self):<br>
super(Net, self).<strong>init</strong>()<br>
self.fc1 = nn.Linear(32,2048)<br>
self.fc2 = nn.Linear(2048,64)<br>
self.fc3 = nn.Linear(64,10)<br>
self.dropout = nn.Dropout(0.10)<br>
def forward(self, x):<br>
x = self.fc1(x)<br>
x = F.relu(x)<br>
print(“x.shape”,x.shape)<br>
x = self.dropout(x)<br>
x = self.fc2(x)<br>
x = F.relu(x)<br>
x = self.fc3(x)<br>
x = F.relu(x)</p>
<pre><code>    output = F.log_softmax(x, dim=-1)
    return output
</code></pre>
<p>Can anyone please help me in deciding the neurons.</p>

username: ptrblck
cooked: <p>Double post from <a href="https://discuss.pytorch.org/t/runtimeerror-mat1-and-mat2-shapes-cannot-be-multiplied-64x13056-and-153600x2048/101315/213">here</a>.</p>
Modify process group during runtime

username: HodBadichi
cooked: <p>I have three GPUs labeled with ranks [0, 1, 2]. If rank 2 encounters a deadlock, causing a timeout, I aim to sustain the functionality of the remaining two ranks by initiating a new group. Given that only all_reduce operations are involved, it should function correctly dimension-wise. However, to execute this, I need to utilize <code>init_process_group</code> , which in turn necessitates <code>destroy_process_group</code> . The challenge arises from my limited control over rank 2 as both functions require all processes to call them. Is there a method to adjust the communicator during runtime using torch?</p>
Training on CPU with intel_extension_for_pytorch

username: vinayburugu
cooked: <p>model.train()<br>
model, optimizer = ipex.optimize(model, optimizer=optimizer, dtype=torch.float)</p>
<p>I am running into below issue when trying to use the ipex optimize API on  AMD EPYC 7R32</p>
<p>File “/opt/conda/envs/vpytorch/lib/python3.10/site-packages/intel_extension_for_pytorch/frontend.py”, line 563, in optimize<br>
) = weight_prepack_with_ipex(<br>
File “/opt/conda/envs/vpytorch/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/utils/_weight_prepack.py”, line 541, in weight_prepack_with_ipex<br>
opt_model, opt_optmizer, params_attr = convert_rec(<br>
File “/opt/conda/envs/vpytorch/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/utils/_weight_prepack.py”, line 537, in convert_rec<br>
setattr(new_m, name, convert_rec(sub_m, optimizer, params_attr)[0])<br>
File “/opt/conda/envs/vpytorch/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/utils/_weight_prepack.py”, line 537, in convert_rec<br>
setattr(new_m, name, convert_rec(sub_m, optimizer, params_attr)[0])<br>
File “/opt/conda/envs/vpytorch/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/utils/_weight_prepack.py”, line 537, in convert_rec<br>
setattr(new_m, name, convert_rec(sub_m, optimizer, params_attr)[0])<br>
[Previous line repeated 2 more times]<br>
File “/opt/conda/envs/vpytorch/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/utils/_weight_prepack.py”, line 535, in convert_rec<br>
new_m = convert(m, optimizer, params_attr)<br>
File “/opt/conda/envs/vpytorch/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/utils/_weight_prepack.py”, line 499, in convert<br>
param_wrapper.prepack(m, is_training)<br>
File “/opt/conda/envs/vpytorch/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/utils/_parameter_wrapper.py”, line 475, in prepack<br>
self.linear_prepack(module, is_training)<br>
File “/opt/conda/envs/vpytorch/lib/python3.10/site-packages/intel_extension_for_pytorch/nn/utils/_parameter_wrapper.py”, line 578, in linear_prepack<br>
self.op_ctx = torch.ops.ipex_prepack.linear_prepack(<br>
File “/opt/conda/envs/vpytorch/lib/python3.10/site-packages/torch/_ops.py”, line 692, in <strong>call</strong><br>
return self._op(*args, **kwargs or {})<br>
RuntimeError: could not create a primitive descriptor for an inner product forward propagation primitive</p>
Unable to import torch in visual studios

username: moemoussa
cooked: <p>good day to everyone,<br>
im new to using pytorch so bare with me , i downloaded pytorch using pip and conda , and both the gpu and the cpu versions but i keep getting the same error using visual studio which is :<br>
PS C:\Users\moham&gt; &amp; C:/Users/moham/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/Users/moham/Desktop/thesis/QNetwork.py<br>
Traceback (most recent call last):<br>
File “c:\Users\moham\Desktop\thesis\QNetwork.py”, line 1, in <br>
import torch<br>
File “C:\Users\moham\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch_<em>init</em>_.py”, line 141, in <br>
raise err<br>
OSError: [WinError 126] The specified module could not be found. Error loading “C:\Users\moham\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\lib\shm.dll” or one of its dependencies.<br>
PS C:\Users\moham&gt; &amp; C:/Users/moham/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/Users/moham/Desktop/thesis/QNetwork.py<br>
Traceback (most recent call last):<br>
File “c:\Users\moham\Desktop\thesis\QNetwork.py”, line 1, in <br>
import torch<br>
File “C:\Users\moham\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch_<em>init</em>_.py”, line 141, in <br>
raise err<br>
OSError: [WinError 126] The specified module could not be found. Error loading “C:\Users\moham\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\lib\shm.dll” or one of its dependencies.</p>
<p>i tried EVERYTHING on the internet and even put the path manually in the environment variables but i keep getting this error my python version is 3.10.11 and here is my code for context :<br>
import torch<br>
import torch.nn as nn<br>
import torch.nn.functional as F</p>
<p>class QNetwork(nn.Module):<br>
def <strong>init</strong>(self, input_size, output_size):<br>
super(QNetwork, self).<strong>init</strong>()<br>
self.fc1 = nn.Linear(input_size, 128)<br>
self.fc2 = nn.Linear(128, 64)<br>
self.fc3 = nn.Linear(64, output_size)</p>
<pre><code>def forward(self, x):
    x = F.relu(self.fc1(x))
    x = F.relu(self.fc2(x))
    x = self.fc3(x)
    return x
</code></pre>

username: ptrblck
cooked: <p>Same issue as described <a href="https://discuss.pytorch.org/t/cuda-not-available-for-rtx-6000-mobile/202160/12">here</a>. Apply the suggested workaround from the GitHub issue or install the latest nightly binary.</p>

username: moemoussa
cooked: <p>hey thank you , simply downloading pytorch 2.2 solved the issue</p>
How to trace a custom autograd function

username: Ali_Arastehfard
cooked: <p>Can anyone please help me workaround PyTorch’s limitation on tracing a custom auto-grad function? I found many discussions around the same topic in this community but it still doesn’t seem that there is any fix to it. Here are some discussions (issues) I looked through already:<br>
<a href="https://github.com/pytorch/pytorch/pull/22329" rel="noopener nofollow ugc">https://github.com/pytorch/pytorch/pull/22329</a><br>
Also issues:<br>
22582, 69741, 32822, 75935 and 32822<br>
I really need this for my research but I cannot figure out how to work around it. I read <a href="https://lernapparat.de/pytorch-traceable-differentiable" rel="noopener nofollow ugc">this</a> too but couldn’t understand how and where to implement the solution (for one thing, I can’t find the <code>csrc</code> file in the installation path). I need to trace my model and save it in <code>.pt</code> format to load it again with Rust language. I have a custom auto-grad function. <code>Torch.jit.trace(model, example)</code> works just fine but when I try to save it by <code>traced_model.save(path.pt)</code> I get this same error as in the above discussions (back in 2019 haha).</p>
<pre><code class="lang-auto">Remove calls to Python functions before export. 
Did you forget to add @script or @script_method annotation? 
If this is a nn.ModuleList, add it to __constants__
</code></pre>
<p><a class="mention" href="/u/tom">@tom</a> <a class="mention" href="/u/ngimel">@ngimel</a></p>

username: simosechi
cooked: <p>There is any update?</p>
Video action recognition with small dataset (non human). What model would you recommend?

username: aendrs
cooked: <p>I’m planning to do a video action recognition network (for primate videos, not human). The video dataset will be small in comparison to the gigantic human-centric ones available for benchmark and training. The only advantage I see is that I will have a very reduced number of classes in comparison to the human datasets.</p>
<p>My question is, from the available models of video action recognition which one do you think it’s a good starting point for doing transfer learning considering my data limitations?</p>
<p>Thanks</p>

username: cortical_iv
cooked: <p>Did you ever get this working I’m interested in this topic!</p>
Cuda 10.2 and pytorch 1.5 -- OSError: [WinError 126] The specified module could not be found

username: triggeron
cooked: <p>Getting below issue when after installing cuda 10.2 and installing pytorch 1.5  ‘conda install pytorch torchvision cudatoolkit=10.2 -c pytorch’ . Any ideas how to fix this issue?</p>
<hr>
<p>OSError                                   Traceback (most recent call last)<br>
 in <br>
----&gt; 1 import torch</p>
<p>~\Documents\Anaconda3\lib\site-packages\torch_<em>init</em>_.py in <br>
79     dlls = glob.glob(os.path.join(th_dll_path, ‘*.dll’))<br>
80     for dll in dlls:<br>
—&gt; 81         ctypes.CDLL(dll)<br>
82<br>
83</p>
<p>~\Documents\Anaconda3\lib\ctypes_<em>init</em>_.py in <strong>init</strong>(self, name, mode, handle, use_errno, use_last_error)<br>
362<br>
363         if handle is None:<br>
–&gt; 364             self._handle = _dlopen(self._name, mode)<br>
365         else:<br>
366             self._handle = handle</p>
<p>OSError: [WinError 126] The specified module could not be found</p>

username: jasg
cooked: <p>you could solve it, I have the same problem???</p>

username: jasg
cooked: <p>I back from version 1.5 to 1.4 and this command<br>
conda install pytorch==1.4.0 torchvision==0.5.0 -c pytorch**</p>

username: triggeron
cooked: <p>what about cuda version  10.2?<br>
is this what you used<br>
conda install pytorch=1.4.0 torchvision=0.5.0 cudatoolkit=10.2 -c pytorch ?</p>

username: triggeron
cooked: <p>Any help is greatly appreciated?</p>

username: jasg
cooked: <p>its ok. I have use this</p>

username: peterjc123
cooked: <p>Please take a look here. <a href="https://discuss.pytorch.org/t/cannot-import-torch-on-jupyter-notebook/79334/3" class="inline-onebox">Cannot import torch on jupyter notebook</a></p>

username: Jyoti_Anand
cooked: <p>This worked great! Thankyou so much for posting solution</p>

username: Sardar_Moazzam_Sajid
cooked: <p>can you please explain me i am getting the same error again</p>
Problem with a custom loss function

username: charlymg1982
cooked: <p>Hello! I am writing a custom loss function, and I am encountering a weird issue, which may be related to the way gradients are computed, but I am not sure, so any help would be appreciated. In a nutshell, I am testing a model. I simulate artificial data, and then I check the recovered outcome of the neural network. If that outcome is close to the simulated one, then the code is working well. Now, I have a custom loss function where all works fine, and it includes this:</p>
<pre><code class="lang-auto">class TrendModelLoss(nn.Module):

  def __init__(self, theta, scaling, nT, YL):

    super(TrendModelLoss, self).__init__()
    # Fixed quantities
    self.theta    = theta
    self.scaling  = scaling
    self.nT       = nT
    self.YL       = YL 
    # Estimated parameters
    self.sigma    = nn.Parameter(torch.tensor([-1.0]))
    self.m0       = nn.Parameter(torch.tensor([0.0]))


  def forward(self, predictions, targets):

    # Rescale sigma
    sigma_exp = torch.exp(self.sigma)

    # Initialize m_t as None
    m_t = None

    # Allocate space for the vector m_t for all time steps
    m_vector = torch.zeros_like(predictions)

    # Some code that transforms the predictions into m_vector...

    # Calculate likelihood for y_t
    squared_diff = (m_vector - targets) ** 2
    loss = torch.sum(squared_diff) / (2 * sigma_exp ** 2) + nT / 2 * torch.log(sigma_exp ** 2)
    - 0.5*(sigma_exp ** 2) # PRIORS

    return loss

</code></pre>
<p>This one works very well, and even the parameter sigma is estimated to be the one that I use to simulate artificial data. However, suppose that I just change one line in the loss function:</p>
<pre><code class="lang-auto">squared_diff = (((1.0 - 0.0) * m_vector + 0.0 * self.YL[:,0]) - targets) ** 2
</code></pre>
<p>This should be totally equivalent to the previous code, given that I multiply by 0.0 or 1.0. If I train the model now, things go very bad and sigma explodes. I cannot recover properly the true simulated values of the network. The loss values are also extremely high.</p>
<p>Does anyone know what may be happening?</p>
<p>Thank you!</p>

username: KFrank
cooked: <p>Hi Charly!</p>
<aside class="quote no-group" data-username="charlymg1982" data-post="1" data-topic="202636" data-full="true">
<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/c/e99b99/48.png" class="avatar"> charlymg1982:</div>
<blockquote>
<pre><code class="lang-auto">squared_diff = (((1.0 - 0.0) * m_vector + 0.0 * self.YL[:,0]) - targets) ** 2
</code></pre>
<p>This should be totally equivalent to the previous code</p>
</blockquote>
</aside>
<p>I suspect that the shapes may be different, leading to different broadcasting.</p>
<p>Try printing out the shapes of <code>m_vector</code>, <code>self.YL</code>, <code>self.YL[:, 0]</code>, and <code>targets</code>.</p>
<p>Best.</p>
<p>K. Frank</p>

username: charlymg1982
cooked: <p>That was it! I was mixing 1D and 2D tensors. Thank you very much!</p>
Cannot import torch on jupyter notebook

username: Marwan_Khalil
cooked: <p>When I try to import troch on Jupyter notebook, I receive this error</p>
<pre><code class="lang-auto">OSError                                   Traceback (most recent call last)
&lt;ipython-input-2-eb42ca6e4af3&gt; in &lt;module&gt;
----&gt; 1 import torch

C:\Users\Al Badr\Anaconda3\lib\site-packages\torch\__init__.py in &lt;module&gt;
     79     dlls = glob.glob(os.path.join(th_dll_path, '*.dll'))
     80     for dll in dlls:
---&gt; 81         ctypes.CDLL(dll)
     82 
     83 

C:\Users\Al Badr\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    362 
    363         if handle is None:
--&gt; 364             self._handle = _dlopen(self._name, mode)
    365         else:
    366             self._handle = handle

OSError: [WinError 126] The specified module could not be found

</code></pre>

username: ptrblck
cooked: <p>This error seems to be raise a few times recently, <a href="https://discuss.pytorch.org/t/cuda-10-2-and-pytorch-1-5-oserror-winerror-126-the-specified-module-could-not-be-found/79068">here</a> and <a href="https://discuss.pytorch.org/t/i-have-pytorch-problem/79111">here</a>.</p>
<p>CC <a class="mention" href="/u/peterjc123">@peterjc123</a> as it seems to be Windows-specific.</p>

username: peterjc123
cooked: <p>This is most probably because you are using a CUDA variant of PyTorch on a system that doesn’t have GPU driver installed. That is to say, if you don’t have a Nvidia GPU card, please install the cpu-only package according to the commands on <a href="https://pytorch.org" rel="nofollow noopener">https://pytorch.org</a>.</p>
<pre><code class="lang-auto"># Conda
conda install pytorch torchvision cpuonly -c pytorch
# Pip
pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
</code></pre>

username: jasg
cooked: <p>but in script say: cpu, if I work with CUDA</p>

username: Sardar_Moazzam_Sajid
cooked: <p>i have used try to install it using the commands given on pytorch website for windows but still getting the same error</p>
Memory Leak in torch.load()

username: Mireia_Planas
cooked: <p>I’ve discovered a memory leak in torch.load() when loading a saved tensor. Despite explicitly deleting the loaded object and invoking garbage collection, the memory usage does not decrease as expected.</p>
<p>I created the following issue to address it: <a href="https://github.com/pytorch/pytorch/issues/126159" class="inline-onebox" rel="noopener nofollow ugc">Memory Leak in torch.load() · Issue #126159 · pytorch/pytorch · GitHub</a></p>
<p>I would greatly appreciate any help to solve this problem.</p>