KanduriR
KanduriR

Reputation: 121

Importing librosa package with AWS lambda throws OSError('sndfile library not found')

I am trying to run Librosa package in the AWS lambda function. Now the package library size along with dependencies is much bigger to use lambda layers or the .zip file using S3. Hence I'm using the option of mounting an EFS file system onto the lambda function. I've followed this tutorial here and could install numpy and test that the mounting path works with lambda. I am using an Amazon Linux 2 AMI for my Ec2 instance.

Here is the error I have observed when importing librosa to the lambda library. enter image description here It throws me an error with sndfile library not found in soundfile.py

My EFS file mount absolute path in EC2 is /home/ec2-user/mountpoint/pylib where all my python library files are installed using pip install --upgrade --target pylib/ <library-name>

Following the steps here I've installed the sndfile library also in pylib as

./configure --prefix=/home/ec2-user/mountpoint/pylib/sndfile --disable-static && make 
make install

The output of make install is 
----------------------------------------------------------------------
Libraries have been installed in:
   /home/ec2-user/mountpoint/pylib/sndfile/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /usr/bin/mkdir -p '/home/ec2-user/mountpoint/pylib/sndfile/include'
 /usr/bin/install -c -m 644 sndfile.hh '/home/ec2-user/mountpoint/pylib/sndfile/include'
 /usr/bin/mkdir -p '/home/ec2-user/mountpoint/pylib/sndfile/include'
 /usr/bin/install -c -m 644 sndfile.h '/home/ec2-user/mountpoint/pylib/sndfile/include'

The soundfile.py uses ctypes.util.find_library function to locate sndfile. I am unsure of how to resolve this issue now. What is the path the soundfile.py searching for sndfile library? Would really appreciate if anyone can give me a clue on this.

Upvotes: 1

Views: 898

Answers (1)

kingsleyzissou
kingsleyzissou

Reputation: 36

This is may be a bit late, but I've found myself in the exact same position. What seemed to work for me was to downgrade the lambda runtime to python 3.7. I still had to compile the libsndfile from source, but everything seems to be running now using EFS.

Upvotes: 0

Related Questions