Skip to content

Segfault when using together with Pandas #2348

@maciejkula

Description

@maciejkula

When both PyTorch and Pandas are imported, calling loss.backward() results in a segfault. The issue was originally reported by @EthanRosenthal here

It looks like calling PyThreadState_GET() returns a null pointer here: https://github.com/python/cpython/blob/5fd33b5926eb8c9352bf5718369b4a8d72c4bb44/Python/errors.c#L28

Examining in GDB:

(gdb) down
#0  PyErr_Restore (type=0x0, value=<optimised out>, traceback=0x0) at Python/errors.c:42
42      Python/errors.c: No such file or directory.
(gdb) info locals
tstate = 0x0
oldtype = <optimised out>
oldvalue = <optimised out>
oldtraceback = <optimised out>
(gdb) tstate
Undefined command: "tstate".  Try "help".
(gdb) p tstate

I suspect it's both PyTorch and Pandas doing threading magic and somehow getting in each other's way.

I haven't yet been able to provide a minimal example that triggers this behaviour and does not use my package; it's likely that I'm doing something odd that causes this.

More documentation here: maciejkula/spotlight#42
Possibly related issues: #1318 and #1868.

Python version: 3.6
PyTorch version: v0.2.0
Pandas version: 0.20.1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions