Unhandled SIGSEGV: A segmentation fault occurred

Marcel_Braasch: <p>I built a simple text classifier using LSTM and pytorch lighning. The code is:</p>
<pre><code class="lang-auto">import os
import torch
from torch import nn
import torch.nn.functional as F
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import pytorch_lightning as pl
from dataset import Dataset
from torch.utils.data import DataLoader
from utils import split_dataset
from pytorch_lightning import Trainer

class TextClassifier(pl.LightningModule):

    def __init__(self, dataloader_params=None):
        super().__init__()

        self.dataloader_params = dataloader_params
        self.train, self.test, self.val = split_dataset()
        self.classifier = nn.Sequential(
            nn.LSTM(300, 300),
            nn.Linear(300, 100),
            nn.ReLU(),
            nn.Linear(100, 7)
        )

    def forward(self, x):
        pred = self.classifier(x)
        return pred

    def training_step(self, batch, batch_idx):
        # training_step defined the train loop. It is independent of forward
        y = batch["response"]
        x = batch["documents"]
        y_hat = self.classifier(x)
        loss = nn.CrossEntropyLoss(y_hat, y)
        return loss

    def validation_step(self, batch, batch_idx):
        # training_step defined the train loop. It is independent of forward
        y = batch["response"]
        x = batch["documents"]
        y_hat = self.classifier(x)
        loss = nn.CrossEntropyLoss(y_hat, y)
        self.log('valid_loss', loss, on_step=True)

    def test_step(self, batch, batch_idx):
        # training_step defined the train loop. It is independent of forward
        y = batch["response"]
        x = batch["documents"]
        y_hat = self.classifier(x)
        loss = nn.CrossEntropyLoss(y_hat, y)
        self.log('test_loss', loss)

    def configure_optimizers(self):
        optimizer = torch.optim.Adam(self.parameters(), lr=1e-3)
        return optimizer

    def train_dataloader(self):
        return DataLoader(self.train, **self.dataloader_params)

    def val_dataloader(self):
        return DataLoader(self.val, **self.dataloader_params)

    def test_dataloader(self):
        return DataLoader(self.test, **self.dataloader_params)


dataloader_params = {
    "batch_size": 1,
    "shuffle": True
}

torch.cuda.device("cuda:0")
model = TextClassifier(dataloader_params)
trainer = Trainer()
trainer.fit(model)
</code></pre>
<p>The error message I get is:</p>
<pre><code class="lang-auto">/usr/bin/python3 /home/myname/PycharmProjects/MultiTextClassifier/classifier.py
GPU available: True, used: False
No environment variable for node rank defined. Set as 0.
------------------------------------------------------------------------
/home/myname/.local/lib/python3.8/site-packages/cysignals/signals.cpython-38-x86_64-linux-gnu.so(+0x9424)[0x7f9c697e5424]
/home/myname/.local/lib/python3.8/site-packages/cysignals/signals.cpython-38-x86_64-linux-gnu.so(+0x94d9)[0x7f9c697e54d9]
/home/myname/.local/lib/python3.8/site-packages/cysignals/signals.cpython-38-x86_64-linux-gnu.so(+0xd1af)[0x7f9c697e91af]
/lib/x86_64-linux-gnu/libc.so.6(+0x46210)[0x7f9dd6f6e210]
/home/myname/.local/lib/python3.8/site-packages/google/protobuf/pyext/_message.cpython-38-x86_64-linux-gnu.so(+0x1d178d)[0x7f9c76d8278d]
/home/myname/.local/lib/python3.8/site-packages/google/protobuf/pyext/_message.cpython-38-x86_64-linux-gnu.so(+0x1d1801)[0x7f9c76d82801]
/home/myname/.local/lib/python3.8/site-packages/google/protobuf/pyext/_message.cpython-38-x86_64-linux-gnu.so(_ZN6google8protobuf8internal11InitSCCImplEPNS1_11SCCInfoBaseE+0x6d)[0x7f9c76d8363d]
/home/myname/.local/lib/python3.8/site-packages/tensorflow/python/../libtensorflow_framework.so.2(_ZN10tensorflow9KernelDefC1Ev+0x8d)[0x7f9c5215c29d]
/home/myname/.local/lib/python3.8/site-packages/tensorflow/python/../libtensorflow_framework.so.2(_ZN10tensorflow16KernelDefBuilderC1EPKc+0x2a)[0x7f9c51bb59ca]
/home/myname/.local/lib/python3.8/site-packages/tensorflow/python/../libtensorflow_framework.so.2(+0x6fbd14)[0x7f9c514fad14]
/lib64/ld-linux-x86-64.so.2(+0x11b8a)[0x7f9dd7144b8a]
/lib64/ld-linux-x86-64.so.2(+0x11c91)[0x7f9dd7144c91]
/lib/x86_64-linux-gnu/libc.so.6(_dl_catch_exception+0xe5)[0x7f9dd708b915]
/lib64/ld-linux-x86-64.so.2(+0x1642d)[0x7f9dd714942d]
/lib/x86_64-linux-gnu/libc.so.6(_dl_catch_exception+0x88)[0x7f9dd708b8b8]
/lib64/ld-linux-x86-64.so.2(+0x155fa)[0x7f9dd71485fa]
/lib/x86_64-linux-gnu/libdl.so.2(+0x134c)[0x7f9dd6f0034c]
/lib/x86_64-linux-gnu/libc.so.6(_dl_catch_exception+0x88)[0x7f9dd708b8b8]
/lib/x86_64-linux-gnu/libc.so.6(_dl_catch_error+0x33)[0x7f9dd708b983]
/lib/x86_64-linux-gnu/libdl.so.2(+0x1b59)[0x7f9dd6f00b59]
/lib/x86_64-linux-gnu/libdl.so.2(dlopen+0x4a)[0x7f9dd6f003da]
/usr/bin/python3(_PyImport_FindSharedFuncptr+0x6f)[0x67305f]
/usr/bin/python3(_PyImport_LoadDynamicModuleWithSpec+0x15b)[0x68308b]
/usr/bin/python3[0x684521]
/usr/bin/python3[0x5c4d80]
/usr/bin/python3(PyVectorcall_Call+0x58)[0x5f3798]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x6435)[0x570f85]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x5736)[0x570286]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x849)[0x56b399]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3[0x5f4ca1]
/usr/bin/python3(_PyObject_CallMethodIdObjArgs+0x198)[0x5f5108]
/usr/bin/python3(PyImport_ImportModuleLevelObject+0x823)[0x552f53]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x2a8a)[0x56d5da]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(PyEval_EvalCode+0x27)[0x68c4a7]
/usr/bin/python3[0x6004f4]
/usr/bin/python3[0x5c4d80]
/usr/bin/python3(PyVectorcall_Call+0x58)[0x5f3798]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x6435)[0x570f85]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x5736)[0x570286]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x849)[0x56b399]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3[0x5f4ca1]
/usr/bin/python3(_PyObject_CallMethodIdObjArgs+0x198)[0x5f5108]
/usr/bin/python3(PyImport_ImportModuleLevelObject+0x823)[0x552f53]
/usr/bin/python3[0x4f5bd8]
/usr/bin/python3(PyCFunction_Call+0x59)[0x5f4249]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x6435)[0x570f85]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3[0x5f4ca1]
/usr/bin/python3(_PyObject_CallMethodIdObjArgs+0x198)[0x5f5108]
/usr/bin/python3(PyImport_ImportModuleLevelObject+0x4f8)[0x552c28]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x2a8a)[0x56d5da]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(PyEval_EvalCode+0x27)[0x68c4a7]
/usr/bin/python3[0x6004f4]
/usr/bin/python3[0x5c4d80]
/usr/bin/python3(PyVectorcall_Call+0x58)[0x5f3798]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x6435)[0x570f85]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x5736)[0x570286]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x849)[0x56b399]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3[0x5f4ca1]
/usr/bin/python3(_PyObject_CallMethodIdObjArgs+0x198)[0x5f5108]
/usr/bin/python3(PyImport_ImportModuleLevelObject+0x823)[0x552f53]
/usr/bin/python3[0x4f5bd8]
/usr/bin/python3(PyCFunction_Call+0x59)[0x5f4249]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x6435)[0x570f85]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3[0x5f4ca1]
/usr/bin/python3(_PyObject_CallMethodIdObjArgs+0x198)[0x5f5108]
/usr/bin/python3(PyImport_ImportModuleLevelObject+0x823)[0x552f53]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x2a8a)[0x56d5da]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(PyEval_EvalCode+0x27)[0x68c4a7]
/usr/bin/python3[0x6004f4]
/usr/bin/python3[0x5c4d80]
/usr/bin/python3(PyVectorcall_Call+0x58)[0x5f3798]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x6435)[0x570f85]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x5736)[0x570286]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x849)[0x56b399]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3[0x5f4ca1]
/usr/bin/python3(_PyObject_CallMethodIdObjArgs+0x198)[0x5f5108]
/usr/bin/python3(PyImport_ImportModuleLevelObject+0x823)[0x552f53]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x2a8a)[0x56d5da]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x71e)[0x56b26e]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3[0x50a24c]
/usr/bin/python3[0x5f4ca1]
/usr/bin/python3(PyObject_CallFunctionObjArgs+0x95)[0x5f4f65]
/usr/bin/python3[0x599a8b]
/usr/bin/python3[0x59c217]
/usr/bin/python3(PyObject_GetAttr+0x192)[0x5bfb52]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x64e)[0x56b19e]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3[0x59c95d]
/usr/bin/python3(_PyObject_MakeTpCall+0x1ff)[0x5f463f]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x5969)[0x5704b9]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3[0x59c95d]
/usr/bin/python3(_PyObject_MakeTpCall+0x1ff)[0x5f463f]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x5969)[0x5704b9]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x849)[0x56b399]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3[0x59c6f0]
/usr/bin/python3[0x5a7bf7]
/usr/bin/python3(PyObject_Call+0x25e)[0x5f3f3e]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x1f42)[0x56ca92]
/usr/bin/python3[0x502b4f]
/usr/bin/python3(PyObject_GetAttr+0x267)[0x5bfc27]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x64e)[0x56b19e]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3(PyObject_Call+0x62)[0x5f3d42]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x1f42)[0x56ca92]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x849)[0x56b399]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6)[0x5f7146]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x849)[0x56b399]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393)[0x5f7323]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x849)[0x56b399]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a)[0x56955a]
/usr/bin/python3(PyEval_EvalCode+0x27)[0x68c4a7]
/usr/bin/python3[0x67bc91]
/usr/bin/python3[0x67bd0f]
/usr/bin/python3(PyRun_FileExFlags+0x9b)[0x67bdcb]
/usr/bin/python3(PyRun_SimpleFileExFlags+0x17e)[0x67de4e]
/usr/bin/python3(Py_RunMain+0x212)[0x6b6032]
/usr/bin/python3(Py_BytesMain+0x2d)[0x6b63bd]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7f9dd6f4f0b3]
/usr/bin/python3(_start+0x2e)[0x5fa4de]
------------------------------------------------------------------------
Attaching gdb to process id 7044.
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
&lt;http://www.gnu.org/software/gdb/bugs/&gt;.
Find the GDB manual and other documentation resources online at:
    &lt;http://www.gnu.org/software/gdb/documentation/&gt;.

For help, type "help".
Type "apropos word" to search for commands related to "word".
[New LWP 7087]
[New LWP 7088]
[New LWP 7089]
[New LWP 7090]
[New LWP 7091]
[New LWP 7092]
[New LWP 7093]
[New LWP 7094]
[New LWP 7095]
[New LWP 7096]
[New LWP 7097]
[New LWP 7098]
[New LWP 7099]
[New LWP 7100]
[New LWP 7101]
[New LWP 7105]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f9dd700ddff in __GI___wait4 (pid=7106, stat_loc=stat_loc@entry=0x0, 
    options=options@entry=0, usage=usage@entry=0x0)
    at ../sysdeps/unix/sysv/linux/wait4.c:27

Stack backtrace
---------------
    stat_loc=stat_loc@entry=0x0, options=options@entry=0, 
    usage=usage@entry=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:27
        resultvar = 18446744073709551104
        sc_cancel_oldtype = 0
        sc_ret = &lt;optimized out&gt;
#1  0x00007f9dd700dd7b in __GI___waitpid (pid=&lt;optimized out&gt;, 
    stat_loc=stat_loc@entry=0x0, options=options@entry=0) at waitpid.c:38
No locals.
#2  0x00007f9c697e3ba4 in print_enhanced_backtrace ()
    at build/src/cysignals/implementation.c:563
        parent_pid = 7044
        pid = &lt;optimized out&gt;
#3  0x00007f9c697e5516 in sigdie (sig=sig@entry=11, 
    s=s@entry=0x7f9c697eea48 "Unhandled SIGSEGV: A segmentation fault occurred.") at build/src/cysignals/implementation.c:589
No locals.
#4  0x00007f9c697e91af in sigdie_for_sig (inside=0, sig=11)
    at build/src/cysignals/implementation.c:164
No locals.
#5  cysigs_signal_handler (sig=11) at build/src/cysignals/implementation.c:262
        inside = &lt;optimized out&gt;
#6  &lt;signal handler called&gt;
No locals.
#7  0x00007f9c76d8278d in ?? ()
   from /home/myname/.local/lib/python3.8/site-packages/google/protobuf/pyext/_message.cpython-38-x86_64-linux-gnu.so
No symbol table info available.
#8  0x00007f9c76d82801 in ?? ()
   from /home/myname/.local/lib/python3.8/site-packages/google/protobuf/pyext/_message.cpython-38-x86_64-linux-gnu.so
No symbol table info available.
#9  0x00007f9c76d8363d in google::protobuf::internal::InitSCCImpl(google::protobuf::internal::SCCInfoBase*) ()
   from /home/myname/.local/lib/python3.8/site-packages/google/protobuf/pyext/_message.cpython-38-x86_64-linux-gnu.so
No symbol table info available.
#10 0x00007f9c5215c29d in tensorflow::KernelDef::KernelDef() ()
   from /home/myname/.local/lib/python3.8/site-packages/tensorflow/python/../libtensorflow_framework.so.2
No symbol table info available.
#11 0x00007f9c51bb59ca in tensorflow::KernelDefBuilder::KernelDefBuilder(char const*) ()
   from /home/myname/.local/lib/python3.8/site-packages/tensorflow/python/../libtensorflow_framework.so.2
No symbol table info available.
#12 0x00007f9c514fad14 in _GLOBAL__sub_I_dataset.cc ()
   from /home/myname/.local/lib/python3.8/site-packages/tensorflow/python/../libtensorflow_framework.so.2
No symbol table info available.
#13 0x00007f9dd7144b8a in ?? () from /lib64/ld-linux-x86-64.so.2
No symbol table info available.
#14 0x00007f9dd7144c91 in ?? () from /lib64/ld-linux-x86-64.so.2
No symbol table info available.
#15 0x00007f9dd708b915 in __GI__dl_catch_exception (
    exception=&lt;optimized out&gt;, operate=&lt;optimized out&gt;, args=&lt;optimized out&gt;)
    at dl-error-skeleton.c:182
        old = &lt;optimized out&gt;
        errcode = 0
        c = {exception = 0x7ffe59cf4960, errcode = 0x0, env = {{__jmpbuf = {
                0, 0, 140308464399936, 3271801112, 140730405177696, 
                140308459253760, 140308487330054, 140308460203512}, 
              __mask_was_saved = 1072967184, __saved_mask = {__val = {0, 1, 
                  140308460926440, 140308487680376, 11100312, 200813, 0, 0, 
                  0, 0, 0, 3602926027535567872, 140730405178272, 
                  140730405177920, 10, 1}}}}}
        old = &lt;optimized out&gt;
#16 0x00007f9dd714942d in ?? () from /lib64/ld-linux-x86-64.so.2
No symbol table info available.
#17 0x00007f9dd708b8b8 in __GI__dl_catch_exception (
    exception=&lt;optimized out&gt;, operate=&lt;optimized out&gt;, args=&lt;optimized out&gt;)
    at dl-error-skeleton.c:208
        errcode = 0
        c = {exception = 0x7ffe59cf4b80, errcode = 0x7ffe59cf4a7c, env = {{
              __jmpbuf = {-2, -2684887230387164156, -8, 140730405178240, 
                140315895140448, 2, 2684407974703557636, 
                2704397675338689540}, __mask_was_saved = 0, __saved_mask = {
                __val = {140315884593216, 31524576, 1, 140309760748944, 
                  5674377, 32159168, 4, 140730405179024, 140730405179281, 2, 
                  140730405179281, 140730405178256, 13913146221880982784, 
                  140730405179024, 2, 257}}}}}
        old = 0x7ffe59cf4c70
#18 0x00007f9dd71485fa in ?? () from /lib64/ld-linux-x86-64.so.2
No symbol table info available.
#19 0x00007f9dd6f0034c in dlopen_doit (a=a@entry=0x7ffe59cf4dc0)
    at dlopen.c:66
        args = 0x7ffe59cf4dc0
#20 0x00007f9dd708b8b8 in __GI__dl_catch_exception (
    exception=exception@entry=0x7ffe59cf4d60, 
    operate=operate@entry=0x7f9dd6f002f0 &lt;dlopen_doit&gt;, 
    args=args@entry=0x7ffe59cf4dc0) at dl-error-skeleton.c:208
        errcode = 32669
        c = {exception = 0x7ffe59cf4d60, errcode = 0x7ffe59cf4c6c, env = {{
              __jmpbuf = {31885288, -2685167343650313212, -8, 0, 8691977, 
                140309762444720, 2684407974768569348, 2704397675338689540}, 
              __mask_was_saved = 0, __saved_mask = {__val = {
                  13913146221880982784, 140315884425440, 258, 
                  140730405179024, 140309762444752, 0, 8691977, 
                  140309762444720, 5547197, 206158430232, 140730405178880, 
                  140730405178672, 140315884423808, 31377856, 31671912, 
                  140315884484224}}}}}
        old = 0x0
#21 0x00007f9dd708b983 in __GI__dl_catch_error (
    objname=objname@entry=0x1e687f0, errstring=errstring@entry=0x1e687f8, 
    mallocedp=mallocedp@entry=0x1e687e8, 
    operate=operate@entry=0x7f9dd6f002f0 &lt;dlopen_doit&gt;, 
    args=args@entry=0x7ffe59cf4dc0) at dl-error-skeleton.c:227
        exception = {objname = 0x7f9dd66d7e30 "\020", 
          errstring = 0x1dec9c0 "", message_buffer = 0x7f9dd6741be0 ""}
        errorcode = &lt;optimized out&gt;
#22 0x00007f9dd6f00b59 in _dlerror_run (
    operate=operate@entry=0x7f9dd6f002f0 &lt;dlopen_doit&gt;, 
    args=args@entry=0x7ffe59cf4dc0) at dlerror.c:170
        result = 0x1e687e0
#23 0x00007f9dd6f003da in __dlopen (file=&lt;optimized out&gt;, 
    mode=&lt;optimized out&gt;) at dlopen.c:87
        args = {
          file = 0x7f9c698c8dd0 "/home/myname/.local/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so", mode = 258, 
          new = 0x7f9dd671c7bc, 
          caller = 0x67305f &lt;_PyImport_FindSharedFuncptr+111&gt;}
#24 0x000000000067305f in _PyImport_FindSharedFuncptr ()
No symbol table info available.
#25 0x000000000068308b in _PyImport_LoadDynamicModuleWithSpec ()
No symbol table info available.
#26 0x0000000000684521 in ?? ()
No symbol table info available.
#27 0x00000000005c4d80 in ?? ()
No symbol table info available.
#28 0x00000000005f3798 in PyVectorcall_Call ()
No symbol table info available.
#29 0x0000000000570f85 in _PyEval_EvalFrameDefault ()
No symbol table info available.
#30 0x000000000056955a in _PyEval_EvalCodeWithName ()
...
No symbol table info available.
#180 0x000000000068c4a7 in PyEval_EvalCode ()
No symbol table info available.
#181 0x000000000067bc91 in ?? ()
No symbol table info available.
#182 0x000000000067bd0f in ?? ()
No symbol table info available.
#183 0x000000000067bdcb in PyRun_FileExFlags ()
No symbol table info available.
#184 0x000000000067de4e in PyRun_SimpleFileExFlags ()
No symbol table info available.
#185 0x00000000006b6032 in Py_RunMain ()
No symbol table info available.
#186 0x00000000006b63bd in Py_BytesMain ()
No symbol table info available.
#187 0x00007f9dd6f4f0b3 in __libc_start_main (main=0x4eea30 &lt;main&gt;, argc=2, 
    argv=0x7ffe59cfc2e8, init=&lt;optimized out&gt;, fini=&lt;optimized out&gt;, 
    rtld_fini=&lt;optimized out&gt;, stack_end=0x7ffe59cfc2d8)
    at ../csu/libc-start.c:308
        self = &lt;optimized out&gt;
        result = &lt;optimized out&gt;
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {7037904, 
                -2685168705397167100, 6268080, 140730405208800, 0, 0, 
                2684407978736380932, 2704394687887731716}, 
              mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x2, 
              0x7ffe59cfc2e8}, data = {prev = 0x0, cleanup = 0x0, 
              canceltype = 2}}}
        not_first_call = &lt;optimized out&gt;
#188 0x00000000005fa4de in _start ()
No symbol table info available.
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;


Cython backtrace
----------------
#0  0x00007f9dd700dda0 in __GI___wait4 () at /build/glibc-ZN95T4/glibc-2.31/posix/../sysdeps/unix/sysv/linux/wait4.c:27
#1  0x00007f9dd700dd70 in __GI___waitpid () at /build/glibc-ZN95T4/glibc-2.31/posix/waitpid.c:38
#2  0x00007f9c697e3b30 in print_enhanced_backtrace () at /tmp/pip-install-yn_0bty4/cysignals/build/src/cysignals/implementation.c:563
#3  0x00007f9c697e54a0 in sigdie () at /tmp/pip-install-yn_0bty4/cysignals/build/src/cysignals/implementation.c:589
#4  0x00007f9c697e8fe2 in sigdie_for_sig () at /tmp/pip-install-yn_0bty4/cysignals/build/src/cysignals/implementation.c:164
#5  0x00007f9c697e8fc0 in cysigs_signal_handler () at /tmp/pip-install-yn_0bty4/cysignals/build/src/cysignals/implementation.c:262
#6  0x00007f9dd6f1a3c0 in __restore_rt ()
#7  0x0000000000000000 in ?? ()
#8  0x0000000000000000 in ?? ()
#9  0x0000000000000000 in google::protobuf::internal::InitSCCImpl(google::protobuf::internal::SCCInfoBase*) ()
#10 0x0000000000000000 in tensorflow::KernelDef::KernelDef() ()
#11 0x0000000000000000 in tensorflow::KernelDefBuilder::KernelDefBuilder(char const*) ()
#12 0x0000000000000000 in _GLOBAL__sub_I_dataset.cc ()
#13 0x0000000000000000 in ?? ()
#14 0x0000000000000000 in ?? ()
#15 0x00007f9dd708b830 in __GI__dl_catch_exception () at /build/glibc-ZN95T4/glibc-2.31/elf/dl-error-skeleton.c:182
#16 0x0000000000000000 in ?? ()
#17 0x00007f9dd708b830 in __GI__dl_catch_exception () at /build/glibc-ZN95T4/glibc-2.31/elf/dl-error-skeleton.c:208
#18 0x0000000000000000 in ?? ()
#19 0x00007f9dd6f002f0 in dlopen_doit () at /build/glibc-ZN95T4/glibc-2.31/dlfcn/dlopen.c:66
#20 0x00007f9dd708b830 in __GI__dl_catch_exception () at /build/glibc-ZN95T4/glibc-2.31/elf/dl-error-skeleton.c:208
...
#183 0x000000000067bd30 in PyRun_FileExFlags ()
#184 0x000000000067dcd0 in PyRun_SimpleFileExFlags ()
#185 0x00000000006b5e20 in Py_RunMain ()
#186 0x00000000006b6390 in Py_BytesMain ()
#187 0x00007f9dd6f4efc0 in __libc_start_main () at /build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:308
#188 0x00000000005fa4b0 in _start ()

[Inferior 1 (process 7044) detached]
27	../sysdeps/unix/sysv/linux/wait4.c: Datei oder Verzeichnis nicht gefunden.
Saved trace to /home/myname/PycharmProjects/MultiTextClassifier/cysignals_crash_logs/crash_rsspb6u0.log
------------------------------------------------------------------------
Unhandled SIGSEGV: A segmentation fault occurred.
This probably occurred because a *compiled* module has a bug
in it and is not properly wrapped with sig_on(), sig_off().
Python will now terminate.
------------------------------------------------------------------------

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

</code></pre>
<p>I do not understand the message at all. Whats wrong here?</p>
<p>The <code>DataLoaders</code> return batches of size <code>1</code> (1 because I am processing sentences and they are of variable length, this way I dont need to mask/pad) of the form</p>
<pre><code class="lang-auto">{'response': 0, 'document': tensor([[ 1.0000,  1.0000,  1.0000,  ...,  1.0000,  1.0000,  1.0000],
        [-0.0165,  0.0180, -0.0068,  ..., -0.0015,  0.1011,  0.0275],
        [ 0.0071, -0.1131, -0.0351,  ...,  0.0251,  0.0115,  0.0333],
        ...,
        [-0.0695,  0.0284, -0.0970,  ...,  0.0734,  0.0119,  0.0510],
        [-0.0243, -0.0359,  0.0159,  ...,  0.0246,  0.0299, -0.0102],
        [-0.0620,  0.0514, -0.0746,  ...,  0.0350,  0.0152,  0.0224]],
       dtype=torch.float64)}
</code></pre>
<p>with <code>shape [k,300]</code> where  <code>20 &lt; k &lt; 200</code>.</p>
<p>What’s wrong here?</p>
<p>/edit: I just noticed, <code>y_hat</code> and <code>y</code> are of different shapes. Will change that, but I dont thinkt thats the issue here. I dont even start the training in the first place.</p>

albanD: <p>Hi,</p>
<p>As you can see in the stack trace, the setfault comes from <code>   from /home/myname/.local/lib/python3.8/site-packages/google/protobuf/pyext/_message.cpython-38-x86_64-linux-gnu.so</code>  and <code>   from /home/myname/.local/lib/python3.8/site-packages/tensorflow/python/../libtensorflow_framework.so.2</code></p>
<p>Do you use tensorflow by any chance?</p>

Marcel_Braasch: <p>No, it has nothing to do with tensorflow, I am not using it. Besides my model shown above being incorrect the problem was that I am using an RTX 3090 and my CUDA version was outdated. For others with this problem, running this fixed it:</p>
<p><code>$ /usr/bin/python3 -m pip3 install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html</code></p>
<p>(I have multiple python enviroments hence the specification, you can just leave it out if pip grabs the correct env automatically)</p>