Skip to content

BentoML KMeans error: Exception happened in API function: buffer source array is read-only #1217

Answered by yubozhao
mat-berna asked this question in Q&A
Discussion options

You must be logged in to vote

@Berna4 Thanks for reporting

This error is due to how BentoML is loading SKLearn model with joblib library. Right now, BentoML is loading with mmap_mode to r, and that caused the read-only issue.

Since Sklearn model can be persist with pickle, we can use the PickleArtifacts. For now you can change the iris_classifier.py with the bentoml.service.artifacts.common.PickleArtifact

# iris_clasifier.py
...
# from bentoml.frameworks.sklearn import SklearnModelArtifact
from bentoml.service.artifact.common import PIckleArtifact
...

@artifacts([PickleArtifact('model')])
class IrisClassifier(BentoService):
    @api(...)
    def predict(self, df):
        ...

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mat-berna
Comment options

Answer selected by parano
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants