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

Using Faiss-node in aws having problem working fine locally #25

Closed
abgupta99 opened this issue Jul 7, 2023 · 16 comments · Fixed by #30
Closed

Using Faiss-node in aws having problem working fine locally #25

abgupta99 opened this issue Jul 7, 2023 · 16 comments · Fixed by #30
Assignees
Labels
bug Something isn't working

Comments

@abgupta99
Copy link

Describe the bug
A clear and concise description of what the bug is.

Environment:

  • Operating system: [e.g. Windows x64]
  • Nodejs Version: [e.g. v18.15.0]
  • Package Version: [e.g. v0.1.0]

To Reproduce
Steps to reproduce the behavior:
1.
2.

Expected behavior
should be run succesfully and store text in form of vector store

Screenshots
"errorType": "Error",
"errorMessage": "Could not import faiss-node. Please install faiss-node as a dependency with, e.g. npm install -S faiss-node and make sure you have libomp installed in your path.\n\nError: /opt/nodejs/node18/node_modules/faiss-node/build/Release/faiss-node.node: cannot open shared object file: No such file or directory",
"trace": [
"Error: Could not import faiss-node. Please install faiss-node as a dependency with, e.g. npm install -S faiss-node and make sure you have libomp installed in your path.",
"",
"Error: /opt/nodejs/node18/node_modules/faiss-node/build/Release/faiss-node.node: cannot open shared object file: No such file or directory",
" at FaissStore.importFaiss (file:///opt/nodejs/node18/node_modules/langchain/dist/vectorstores/faiss.js:207:19)",
" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
" at async FaissStore.addVectors (file:///opt/nodejs/node18/node_modules/langchain/dist/vectorstores/faiss.js:60:37)",
" at async FaissStore.fromDocuments (file:///opt/nodejs/node18/node_modules/langchain/dist/vectorstores/faiss.js:197:9)",
" at async Runtime.handler (file:///var/task/index.mjs:57:19)"
]
}

.

@abgupta99 abgupta99 added the bug Something isn't working label Jul 7, 2023
@ewfian
Copy link
Owner

ewfian commented Jul 11, 2023

@abgupta99 Thank you for the issue, I will try to reproduce and fix it

@ewfian ewfian self-assigned this Jul 11, 2023
@dmb0058
Copy link

dmb0058 commented Jul 11, 2023

This seems identical to the issue I have with HNSWlib-node.
It might be coincidental, but in case this is a langchainjs issue, not faiss, see:

langchain-ai/langchainjs#943
langchain-ai/langchainjs#1764

@dmb0058
Copy link

dmb0058 commented Jul 11, 2023

Spent the day building test cases for this, and it's the same langchainjs error.

Most approaches end up with:

"Could not import faiss-node. Please install faiss-node as a dependency with, e.g. npm install -S faiss-node.\n\nError: libgomp.so.1: cannot open shared object file: No such file or directory"

Currently I see that there is any route to using langchain with either faiss or hnswnlib on AWS Lambda.

@manuel-84
Copy link

manuel-84 commented Jul 17, 2023

Having similar problem when deployed on Vercel, while on local dev is working fine

Could not import faiss-node. Please install faiss-node as a dependency with, e.g. npm install -S faiss-node.\n\nError: libgomp.so.1: cannot open shared object file: No such file or directory","stack":"

@ewfian
Copy link
Owner

ewfian commented Jul 21, 2023

I have create a build for AWS Lambda in #30

And is was works on my side:
image

It has not been released yet, but you can try the version I built manually below:
faiss-node-v0.2.2-aws-x64.zip

For other projects, please replace with the files under the path below:
faiss-node-v0.2.2-aws-x64.zip/node_modules/faiss-node/build/Release

@dmb0058
Copy link

dmb0058 commented Jul 21, 2023

Hi,

No luck my side I’m afraid: still missing libgomp.so.1:

{
  "errorType": "Error",
  "errorMessage": "Could not import faiss-node. Please install faiss-node as a dependency with, e.g. `npm install -S faiss-node`.\n\nError: libgomp.so.1: cannot open shared object file: No such file or directory",
  "trace": [
    "Error: Could not import faiss-node. Please install faiss-node as a dependency with, e.g. `npm install -S faiss-node`.",
    "",
    "Error: libgomp.so.1: cannot open shared object file: No such file or directory",
    "    at FaissStore.importFaiss (/opt/nodejs/node_modules/langchain/dist/vectorstores/faiss.cjs:237:19)",
    "    at async readIndex (/opt/nodejs/node_modules/langchain/dist/vectorstores/faiss.cjs:141:37)",
    "    at async Promise.all (index 1)",
    "    at async FaissStore.load (/opt/nodejs/node_modules/langchain/dist/vectorstores/faiss.cjs:144:51)",
    "    at async query (/var/task/index.js:112:20)",
    "    at async exports.handler (/var/task/index.js:20:9)"
  ]
}

Also, after adding the Faiss layer I can't add anything much else as it's far too big:

Layers consume more than the available size of 262144000 bytes

David

@ewfian
Copy link
Owner

ewfian commented Jul 22, 2023

@dmb0058 I want to know whether it works properly if you directly upload the zip(faiss-node-v0.2.2-aws-x64.zip) I provided above to AWS.

Please confirm that you have replaced the files(node_modules/faiss-node/build/Release) in my zip above to the zip you finally want to upload to AWS.

I also made a demo for langchain here: langchain-ai/langchainjs#1930 (comment)
You can try to upload this demo directly to AWS.

@dmb0058
Copy link

dmb0058 commented Jul 22, 2023

Yes, the demo zip (faiss-node-v0.2.2-aws-x64.zip) runs when I upload it as a lambda and gives the same results as you show above.

I can't create a layer though, so can't use this in practice:

 aws lambda publish-layer-version --layer-name my-faiss-layer \
        --description "My Faiss layer" \
        --license-info "MIT" \
        --zip-file fileb://my-faiss-node.zip \
        --compatible-runtimes nodejs18.x \
        --compatible-architectures "x86_64"
An error occurred (RequestEntityTooLargeException) when calling the PublishLayerVersion operation: Request must be smaller than 70167211 bytes for the PublishLayerVersion operation

@ewfian
Copy link
Owner

ewfian commented Jul 22, 2023

@dmb0058 Can you reduce the size of the zip to make it meet the limit first.
The prebuilt binaries is too large under Linux was also mentioned in your previous issue(#26).
The binaries for AWS have shrunk a lot. The zip containing faiss-node is only 7.5MB. And the zip containing langchain and faiss-node has 15.5MB. Which is far less than the limit of AWS. Please identify what content takes up space and try to reduce it.

@dmb0058
Copy link

dmb0058 commented Jul 22, 2023 via email

@ewfian
Copy link
Owner

ewfian commented Jul 24, 2023

@dmb0058 You can also try this demo langchain-ai/langchainjs#1930 (comment)

@ewfian ewfian pinned this issue Aug 4, 2023
@ewfian
Copy link
Owner

ewfian commented Aug 7, 2023

The new version was released, To use faiss-node in AWS, you can download faiss-node-vX.X.X-aws-x64.zip from release. and upload to AWS as a layer.
BTW. if you are using the faiss-node as layer, do NOT install faiss-node as npm package in your AWS Function, see the demo here: langchain-ai/langchainjs#1930 (comment)

@rishi-raj-jain
Copy link

This now works flawlessly with Fly.io, I had made a cool demo before and now I don't need to copy the zip folder over.

Thank you for maintaining and improving this 🙏🏻

@rishi-raj-jain
Copy link

@ewfian

I'm happy to pay you one time 30$ as the best I can for now. Can you share a buymeacoffee/paypal/stripe link? Thanks!

@rishi-raj-jain
Copy link

rishi-raj-jain commented Oct 30, 2023

This is totally out of my respect for your work.

@afsaints
Copy link

afsaints commented Apr 9, 2024

The newer version is still cannot get through on the lambda layers, still having the same error which is
{
"errorType": "Error",
"errorMessage": "Could not import faiss-node. Please install faiss-node as a dependency with, e.g. npm install -S faiss-node.\n\nError: libgomp.so.1: cannot open shared object file: No such file or directory",
"trace": [
"Error: Could not import faiss-node. Please install faiss-node as a dependency with, e.g. npm install -S faiss-node.",
"",
"Error: libgomp.so.1: cannot open shared object file: No such file or directory",
" at FaissStore.importFaiss (/opt/nodejs/node_modules/langchain/dist/vectorstores/faiss.cjs:237:19)",
" at async readIndex (/opt/nodejs/node_modules/langchain/dist/vectorstores/faiss.cjs:141:37)",
" at async Promise.all (index 1)",
" at async FaissStore.load (/opt/nodejs/node_modules/langchain/dist/vectorstores/faiss.cjs:144:51)",
" at async query (/var/task/index.js:112:20)",
" at async exports.handler (/var/task/index.js:20:9)"
]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants