langchainjs: Langchain doesn't work on AWS Lambda with either faiss or hnswlib
The current version is broken on AWS lambda, both with Faiss and HNSWlib. I’ve spent the last few days building test cases on both platforms, but haven’t dived into the langchain code.
The typical outcome is:
“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”
Same with HNSWlib (substitute hnswlib for faiss in the error above).
Also see
https://github.com/hwchase17/langchainjs/issues/943 https://github.com/hwchase17/langchainjs/issues/1764
Hope this helps - langchain is amazing, and if it worked on AWS it would be even better 😃
David
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 3
- Comments: 25 (4 by maintainers)
There is a document on how to run hnswlib-node on AWS lambda. I managed to deploy it using this dockerfile:
Looking for a lambda layer solution, since I don’t want to deploy using Docker images.
🤖
Based on the error messages you’ve shared, it seems like the AWS Lambda environment is missing some shared libraries required by
faiss-node
andhnswlib
. Specifically, the errors mentionlibgomp.so.1
and/lib64/libm.so.6: version GLIBC_2.27
.One possible workaround is to create a custom AWS Lambda layer that includes these missing shared libraries. Here’s a general outline of the steps:
Create a Dockerfile that uses the Amazon Linux image (which is the same environment that AWS Lambda runs on). In this Dockerfile, install the necessary dependencies and build the shared object files.
Use the Dockerfile to build a Docker image and run a Docker container.
Inside the Docker container, create a zip file that contains the shared object files and dependencies.
Upload the zip file to AWS S3.
Create a new AWS Lambda layer and point it to the zip file in S3.
Add the new layer to your AWS Lambda function.
Please note that the exact steps and code will depend on the specific shared object files and dependencies that are missing.
In the context of LangChain, you would need to ensure that the AWS Lambda environment has the necessary dependencies to run Faiss or HNSWlib, and that the shared object files are included in the AWS Lambda layer.
Unfortunately, without more specific information about the shared object files and dependencies required by Faiss and HNSWlib, I can’t provide more specific steps or code. You might need to consult the documentation or community for these libraries to get this information.
As for the issue with
GLIBC_2.27
, it seems like AWS Lambda’s Amazon Linux 2 environment only includesGLIBC_2.26
. This might be causing the unmet dependencies issue. One possible solution is to wait for AWS to update the version of glibc in their environment, or to find a version offaiss-node
that is compatible withGLIBC_2.26
.I hope this helps! If you have any more questions or need further clarification, feel free to ask.
Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
@jacoblee93 There is also a related issue on faiss-node side. I’ll do some research and try to find a solution.
Are you using the edge runtime?
faiss-node
is Node only 😦