Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows fatal exception: access violation #571

Open
Enquandriant opened this issue Jun 27, 2024 · 0 comments
Open

Windows fatal exception: access violation #571

Enquandriant opened this issue Jun 27, 2024 · 0 comments

Comments

@Enquandriant
Copy link

Hi, I am trying to use this and can't even get the simplest of example code to work.
I have a python environment created with conda

conda create -n "310" python=3.10

with numpy and hnswlib installed by

pip install hnswlib numpy

trying to run this test script

import hnswlib
import numpy as np
import faulthandler
import sys
import os

faulthandler.enable()

print(f"Python version: {sys.version}")
print(f"Process ID: {os.getpid()}")
print(f"numpy version: {np.__version__}")
print(f"hnswlib: {hnswlib}")

dim = 2
num_elements = 3
data = np.float32(np.random.random((num_elements, dim)))
ids = np.arange(num_elements)

print("Data:")
print(data)
print("IDs:")
print(ids)

try:
    p = hnswlib.Index(space='l2', dim=dim)  # possible options are l2, cosine or ip
    p.init_index(max_elements=num_elements + 10, ef_construction=100, M=8)
    p.add_items(data, ids)
    print("Insertion complete!")
except Exception as e:
    print(f"An error occurred: {e}")

with the following output

(310) C:\Users\User> python test.py
Python version: 3.10.14 | packaged by Anaconda, Inc. | (main, May  6 2024, 19:44:50) [MSC v.1916 64 bit (AMD64)]
Process ID: 14284
numpy version: 2.0.0
hnswlib: <module 'hnswlib' from 'C:\\Users\\User\\miniconda3\\envs\\310\\lib\\site-packages\\hnswlib.cp310-win_amd64.pyd'>
Data:
[[0.35375407 0.4176661 ]
 [0.8533985  0.15651907]
 [0.3862144  0.612005  ]]
IDs:
[0 1 2]
Windows fatal exception: access violation

Current thread 0x000057a4 (most recent call first):
  File "C:\Users\User\test.py", line 27 in <module>

noting that line 27 is

    p.add_items(data, ids)

It crashes every time I try to add any data to the index. Any advice/ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant