Kernel death confusion

Revan: <p>Hey everyone,</p>
<p>Apologies in advance since I’m really new to pytorch and machine learning in general,</p>
<p>I’m trying to run a notebook where I convert data in the form of a list of 4-element lists into a tensor, then shuffle that data. When I start to shuffle the tensor based on random indices, the kernel dies, and I’m lost as to why. Can anyone help explain what’s going on here?</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/e/0e85ae23bfa71c9e8dcedabb186aa95af330094e.png" data-download-href="https://discuss.pytorch.org/uploads/default/0e85ae23bfa71c9e8dcedabb186aa95af330094e" title="Screenshot 2024-06-13 at 2.03.46 PM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/0/e/0e85ae23bfa71c9e8dcedabb186aa95af330094e_2_542x500.png" alt="Screenshot 2024-06-13 at 2.03.46 PM" data-base62-sha1="24t5M7IDI4QDbyWk1RSmkzwahA2" width="542" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/0/e/0e85ae23bfa71c9e8dcedabb186aa95af330094e_2_542x500.png, https://discuss.pytorch.org/uploads/default/original/3X/0/e/0e85ae23bfa71c9e8dcedabb186aa95af330094e.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/0/e/0e85ae23bfa71c9e8dcedabb186aa95af330094e.png 2x" data-dominant-color="1F232A"><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">Screenshot 2024-06-13 at 2.03.46 PM</span><span class="informations">810×746 59.4 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>Everything above the screenshot is class/method definitions and import statements, the method adds 4-element lists to the parent list it takes as an argument.</p>
<p>Thanks!</p>

ptrblck: <p>Try to run your code directly in a terminal as it should print an error message.</p>

Revan: <p>There’s not really an error message here, it kind of just prints a ton of statements ending in (no debug info)</p>
<p>I’ve sampled a bit of it below, there’s way more but it looks more or less the same, just with different names:</p>
<blockquote>
<p>[/opt/anaconda3/envs/rootML/lib/libomp.dylib] void __kmp_suspend_64&lt;false, true&gt;(int, kmp_flag_64&lt;false, true&gt;<em>) (no debug info)<br>
[/opt/anaconda3/envs/rootML/lib/python3.11/site-packages/torch/lib/libomp.dylib] kmp_flag_64&lt;false, true&gt;::wait(kmp_info</em>, int, void*) (no debug info)<br>
[/opt/anaconda3/envs/rootML/lib/python3.11/site-packages/torch/lib/libomp.dylib] __kmp_hyper_barrier_release(barrier_type, kmp_info*, int, int, int, void*) (no debug info)<br>
[/opt/anaconda3/envs/rootML/lib/python3.11/site-packages/torch/lib/libomp.dylib] __kmp_fork_barrier(int, int) (no debug info)<br>
[/opt/anaconda3/envs/rootML/lib/python3.11/site-packages/torch/lib/libomp.dylib] __kmp_launch_thread (no debug info)<br>
[/opt/anaconda3/envs/rootML/lib/python3.11/site-packages/torch/lib/libomp.dylib] __kmp_launch_worker(void*) (no debug info)<br>
[/usr/lib/system/libsystem_pthread.dylib] _pthread_start (no debug info)<br>
[/usr/lib/system/libsystem_pthread.dylib] thread_start (no debug info)</p>
</blockquote>

ptrblck: <p><code>libomp</code> might be segfaulting and you could use a debugger, e.g. <code>gdb</code>, to create the stacktrace.</p>

Revan: <p>I use an M1 mac, so gdb doesn’t seem to be an option. Are there any alternatives you can recommend?</p>

Revan: <p>Issue is still going. I’ve retried running in terminal after decoupling a different package, and got the following error:</p>
<pre><code class="lang-auto">rootML) (base) [npolishetty@arm64-apple-darwin20 MachineLearningStatistics (master ✗)]$ ipython modelNetwork.ipynb
No event loop hook running.
[1]    37447 segmentation fault  ipython modelNetwork.ipynb
</code></pre>

Revan: <p>Tried doing some digging, looks like segmentation faults are related to Cython and memory, so I attached the following lines to highlight the issue:</p>
<pre><code class="lang-auto">data_train = tensorData.view(-1)[idx].view(tensorData.size())
</code></pre>
<p>idx is just torch.randperm(8591). Would this just be the result of an extremely memory inefficient approach? I used the method listed <a href="https://discuss.pytorch.org/t/shuffling-a-tensor/25422/4">here</a>. If it’s just a memory issue, are there any alternative approaches to shuffling that I should look into?</p>

fasterinnerlooper: <p>It does feel like this might be a memory issue. One quick thing you could do is to try running this on another machine with more memory and see if it still fails.<br>
Another thing you could try is some of the top suggestions from this SO thread. If you’re in Python 3.4 then theasmalloc might be the best thing to try, otherwise there appear to be pretty good third party libraries that you could use to see whether this is indeed a memory allocation issue.<br>
I hope these suggestions help you out.</p>

Revan: <p>Thanks for responding, I forgot to check back here to give an update. It was in fact just a memory issue, and after cutting down the amount of data I was feeding, everything worked fine. Thanks!</p>