o19s / hello-nlp

A natural language search microservice
Other
96 stars 12 forks source link

Docker cuda #21

Closed binarymax closed 3 years ago

binarymax commented 3 years ago

This fixes the issue with the sentence_transformers module ("SBERT") not finding the model when installing via Docker. The problem was that the default guvicorn concurrency was set to >1, creating more than one instance of sentence_transformers. When sentence_transformers is instantiated, it checks if a model exists and will download one if not. Both concurrent instances of sentence_transformers were competing to download the same file, corrupting it.

Setting WEB_CONCURRENCY=1 is required the first time the docker container is built and run. After the model is downloaded this first time, the concurrency can be updated.

So, this should be a good enough workaround for now, but in the future it should be possible to set a higher WEB_CONCURRENCY value immediately and let Docker scripts download the model up-front. As a plugin however, the vectorize module shouldnt have a direct impact on Docker config - so perhaps plugins need a bootstrap script that can be run the first time it is seen.