Segmentation Fault in KMeans on OSX
See original GitHub issueDescribe 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:
- Created a year ago
- Comments:17 (12 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It would be very helpful if you could:
conda list
for future referenceconda
environment using theconda-forge
channel,conda create -n test-env -c conda-forge scikit-learn
gdb
orldb
to get a stack-trace from the segmentation fault, see https://github.com/scikit-learn/scikit-learn/issues/23574#issuecomment-1152379936 for gdb@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
You could also use
gdb
to see whether it gives some useful additional infoThen type
r
(for run) and thenbt
(for backtrace). There maybe more info about gdb and python in https://wiki.python.org/moin/DebuggingWithGdb.