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 in KMeans on OSX

See original GitHub issue

Describe the bug

Hi when I run this code

import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)

I get this error

zsh: segmentation fault python debugging.py

This can’t be a memory error, it’s only a 10x2 matrix, any idea what’s wrong?

Python 3.10.4 Anaconda installation

sklearn.version ‘1.0.2’ numpy.version ‘1.22.3’

Steps/Code to Reproduce

import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)

Expected Results

KMeans clusters

Actual Results

zsh: segmentation fault python debugging.py

This can’t be a memory error, it’s only a 10x2 matrix, any idea what’s wrong?

Versions

Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
lestevecommented, Sep 16, 2022

It would be very helpful if you could:

1reaction
lestevecommented, Jun 10, 2022

@EoinKenny as a work-around you may want to try to create a new environment from conda-forge and see whether the problem persists, i.e. something like this

conda create -c conda-forge -n test-env scikit-learn -y
conda activate test-env
python debugging.py

You could also use gdb to see whether it gives some useful additional info

gdb run --args python debugging.py

Then type r (for run) and then bt (for backtrace). There maybe more info about gdb and python in https://wiki.python.org/moin/DebuggingWithGdb.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Segmentation fault: 11 on OSX - Stack Overflow
This is a bug in the python interpreter related to readline compatibility that has been fixed in the most recent candidates that were...
Read more >
Segmentation Fault 11 in multiple system apps
The segmentation fault is a memory failure. Macs are completely intolerant of anything other than RAM that meets Apple's stringent ...
Read more >
Command-line Interface | Karypis Lab - George Karypis
Command-line Interface ; vcluster Segmentation fault, 1 ; Cluto assertion error, 1 ; Does Cluto provide K-means algorithm implementation? 1 ; Descriptive feature ......
Read more >
Troubleshooting GStreamer
What can I do if I get a segmentation fault? · Type "run" at the (gdb) prompt and wait for the application to...
Read more >
A New Ensemble Fault Diagnosis Method Based on K-means ...
Keywords: Fault diagnosis; K-means algorithm; Probabilistic neural network; Ensemble algorithm; ... K-means algorithm was first proposed by J. B. Mac-.
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