Talip7/scikit-learn-issues-multilabel huggingface dataset:
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
I still cannot reproduce with a fully defaults channel environment.

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
Ugh, sorry to hear that, if there's any other information I can provide which may help please let me know thanks.

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
@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

```sh
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.

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
Thanks, I just installed the environment again with python 3.9 and it works, I can still run that code for you though if you'd like to see the data?

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
Could you try to use a debugger and report a post-mortem backtrace?

Not sure how to do that on macos. Maybe you can try to install gdb with homebrew (or maybe `conda install -c conda-forge gdb`) and then do:

```
$ gdb --ex run --ex backtrace --args python /path/to/reproducer_script.py
[...] # program execution output
# the backtrace should show up at the end, after the segfault happens.
```

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
If gdb does not work on macos, lldb might but I am not sure how to use it.

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
Sorry @lesteve I had not seen you reply :)

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
Hello, I am facing the same issue

```
>>> numpy.__version__
1.22.4
>>> sklearn.show_versions()
System:
    python: 3.9.12 (main, Apr  5 2022, 01:53:17)  [Clang 12.0.0 ]
executable: /Users/apple/opt/miniconda3/bin/python
   machine: macOS-10.16-x86_64-i386-64bit

Python dependencies:
      sklearn: 1.1.2
          pip: 21.2.4
   setuptools: 61.2.0
        numpy: 1.22.4
        scipy: 1.8.1
       Cython: None
       pandas: 1.4.3
   matplotlib: 3.5.2
       joblib: 1.1.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: libomp
       filepath: /Users/apple/opt/miniconda3/lib/python3.9/site-packages/torch/.dylibs/libomp.dylib
        version: None
    num_threads: 1

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /Users/apple/opt/miniconda3/lib/python3.9/site-packages/numpy/.dylibs/libopenblas64_.0.dylib
        version: 0.3.18
threading_layer: pthreads
   architecture: Haswell
    num_threads: 2

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /Users/apple/opt/miniconda3/lib/python3.9/site-packages/scipy/.dylibs/libopenblas.0.dylib
        version: 0.3.9
threading_layer: pthreads
   architecture: Haswell
    num_threads: 2

       user_api: openmp
   internal_api: openmp
         prefix: libomp
       filepath: /Users/apple/opt/miniconda3/lib/libomp.dylib
        version: None
    num_threads: 4
```

OS is macOS Monterey 12.5.1

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
It would be very helpful if you could:
- post the output of `conda list` for future reference
- try if the problem persists in a new `conda` environment using the `conda-forge` channel, `conda create -n test-env -c conda-forge scikit-learn`
- try to use a `gdb` or `ldb` to get a stack-trace from the segmentation fault, see https://github.com/scikit-learn/scikit-learn/issues/23574#issuecomment-1152379936 for gdb

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
Same issue for me. M1 Mac. Incase anyone has found a solution

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
@matthewnour and others who can reproduce the problem, could you please post the output on `sklearn.show_versions()` in the environment that can trigger the problem? See @jacktang's report here.

https://github.com/scikit-learn/scikit-learn/issues/23574#issuecomment-1248889181

In particular I am interested if you also have torch's openmp in the output and if so how did you install torch on your machine: do you use pip or conda. Ideally please include a set of pip or conda commands that make it possible to create a new venv or conda env that can trigger the problem.

Personally I do not experience this problem on my M1 laptop and I install most dependencies from conda-forge (using mambaforge): https://github.com/conda-forge/miniforge#mambaforge

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
@EoinKenny @matthewnour @jacktang I updated the snippet to make the reproducer deterministic. Do you confirm that you can still reproduce the problem with this updated snippet and the latest version of scikit-learn?

If so, can any of you confirm that this is related to the presence or absence of torch'openmp in the output of threadpoolctl?

I do not understand why would torch's openmp would be linked if you only import numpy or scikit-learn.

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
Also I am still interested in a post-mortem backtrace with GDB or LLDB, see: https://github.com/scikit-learn/scikit-learn/issues/23574#issuecomment-1152620466.

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS
Segmentation Fault in KMeans on OSX

### Describe the bug

Hi when I run this code

```
import numpy as np      
from sklearn.cluster import KMeans

X_train = np.random.RandomState(0).random((10, 2))
kmeans = KMeans(n_clusters=3, random_state=0).fit(X_train)
```

EDIT by @ogrisel: inserted `.RandomState(0)` in the above snippet to make the reproducer deterministic.

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

```shell
Python 3.10.4
Anaconda installation
>>> sklearn.__version__
'1.0.2'
>>> numpy.__version__
'1.22.3'
```

COMMENT:
Also note, we just merged #27167 that might or might not impact the crash you observed in this issue. If anybody who could reproduce #23574 can tell me if #27167 fixes the problem for them, that would be very nice.

Labels: Bug, Documentation, help wanted, module:cluster, OS:macOS