question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Segmentation Fault with Pandas

See original GitHub issue

I ran into a very odd segmentation fault error. This could very well be a PyTorch bug, but I thought I’d bring it up here, first. I’ve produced a minimal example at the bottom of this issue.

So far, I know that the fault happens at the loss.backward() call in model.fit(). The fault only seems to happen under the combination of two conditions (that I can find, so far):

  1. When sparse=True.
  2. Pandas is imported at the top of the file

(BTW, I pass in an SGD optimizer because that seems to be the only one that works right now with sparse embeddings)

I’m using pandas version 0.20.3 from conda, the latest spotlight from master, and PyTorch 0.2.0 from conda. I’d love to know if others can reproduce this.

As I said, this could very well be a PyTorch bug, but, if others run into this, it’ll be helpful to have this issue as a reference.

import pandas as pd
import numpy as np
import torch

from spotlight.interactions import Interactions
from spotlight.factorization.implicit import ImplicitFactorizationModel

user_ids = [2471, 5808, 3281, 4086, 6293, 8970, 11828, 3281]
item_ids = [1583, 57, 6963, 867, 8099, 10991, 24, 800]
num_users = 15274
num_items = 25655

train = Interactions(np.array(user_ids, dtype=np.int64),
                     np.array(item_ids, dtype=np.int64),
                     num_users=num_users,
                     num_items=num_items)

def optimizer_func(params, lr=0.01):
    return torch.optim.SGD(params, lr=lr)
  
RANDOM_STATE = np.random.RandomState(42)
model = ImplicitFactorizationModel(loss='bpr',
                                   embedding_dim=32,
                                   batch_size=4,
                                   n_iter=1,
                                   use_cuda=False,
                                   optimizer_func=optimizer_func,
                                   sparse=True,
                                   random_state=RANDOM_STATE)
# Fault
model.fit(train, verbose=True)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
apaszkecommented, Aug 30, 2017

A fix will be soon in master - https://github.com/pytorch/pytorch/pull/2581 Sorry for keeping you waiting!

0reactions
maciejkulacommented, Aug 30, 2017

@apaszke Awesome. Thanks for the amazing work on PyTorch!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pandas segmentation fault - Stack Overflow
I can reproduce the segmentation fault with 0.14.1, sometimes. Can you post an issue on github? github.com/pydata/pandas/issues.
Read more >
BUG: Segmentation fault when importing pandas · Issue #33991
Code Sample, a copy-pastable example​​ I have just downloaded fresh miniconda (python 3, 64 bit) script. Instalation of miniconda went well. Now ...
Read more >
Issue 34688: Segfault in pandas that works fine on 3.7
msg325392 ‑ (view) Author: Karthikeyan Singaravelan (xtreak) * Date: 2018‑09‑14 19:52 msg325420 ‑ (view) Author: Karthikeyan Singaravelan (xtreak) * Date: 2018‑09‑15 03:43 msg325558 ‑ (view)...
Read more >
Segmentation Fault in Pandas read_csv - YouTube
Pandas : Segmentation Fault in Pandas read_csv [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] Pandas : Segmentation ...
Read more >
[#ARROW-2391] [Python] Segmentation fault from PyArrow ...
[Python] Segmentation fault from PyArrow when mapping Pandas datetime column to pyarrow.date64. Status: Assignee: Priority: Resolution: Resolved.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found