I'm using some sound libraries in order to do preprocessing (in inference.py file) before sending the data to the model to make prediction. The problem is one of those libraries is SoundFile which throwing an error when I check CloudWatch "OSError: sndfile library not found" . After some research, I found out that I have to install a package called libsndfile using this command "apt install libsndfile" .
I'm wondering if there's a way to install that package using script mode or another method from within SageMaker besides having to make my own docker image ??
Additional information:
I'm deploying directly from model artifacts
```
sagemaker_model = Model(model_data = 's3://' + sagemaker_session.default_bucket() +'/model/model.tar.gz',
role = role,
framework_version = '2.1.0',
source_dir='my_src',
entry_point = ' inference.py',
env={'SAGEMAKER_REQUIREMENTS': 'requirements.txt'})
Since it's not a pip package I would advice you to extend our container and install the dependency in the docker image and then use your BYOC instead.
Here is an example that might be helpful:
https://github.com/awslabs/amazon-sagemaker-examples/blob/master/advanced_functionality/pytorch_extending_our_containers/pytorch_extending_our_containers.ipynb
@nadiaya Thank you for your response, but I've already created my own custom container from scratch based on Ubuntu 18.04 which already comes with a lot of dependencies that I need built-in.
I don't know if that's a good decision when comparing it to your advice about extending your container. Do you think a Ubuntu docker image is an overkill ??
Here's how my Dockerfile looks like :
FROM ubuntu:18.04
COPY requirements.txt /opt/program/requirements.txt
RUN apt-get -y update && apt-get install -y --no-install-recommends \
software-properties-common \
wget \
nginx \
ca-certificates \
libsndfile1 \
ffmpeg \
frei0r-plugins \
python3-pip python3-dev \
python3-setuptools \
&& cd /usr/local/bin \
&& ln -s /usr/bin/python3 python \
&& pip3 install --upgrade pip
RUN pip3 install --no-cache-dir -r /opt/program/requirements.txt
ENV PYTHONUNBUFFERED=TRUE
ENV PYTHONDONTWRITEBYTECODE=TRUE
ENV PATH="/opt/program:${PATH}"
ENV MODEL_PATH="/opt/ml/model"
# Set up the program in the image
COPY model /opt/program
WORKDIR /opt/program
Most helpful comment
Since it's not a pip package I would advice you to extend our container and install the dependency in the docker image and then use your BYOC instead.
Here is an example that might be helpful:
https://github.com/awslabs/amazon-sagemaker-examples/blob/master/advanced_functionality/pytorch_extending_our_containers/pytorch_extending_our_containers.ipynb