Docker-Compose rasa FULL image can't find SpaCy model

Hi everyone, I’m new with docker, i’m trying to deploy my model on Rasa-X using docker-compose, and i followed the Quick Tutorial by Rasa. After completed all the steps, i can see the model, stories and nlu, but the assistant doesn’t answer to utterances, neither extract the correct user intent.

After a debugging session, i saw that the problem comes from the rasa container: even if i used the rasa/rasa 2.7.2-full image, if i write docker-compose logs rasa-worker, i get this error:

rasa.core.agent  - Failed to update model. The previous model will stay loaded instead.
Traceback (most recent call last):
|   File "/opt/venv/lib/python3.8/site-packages/rasa/nlu/utils/spacy_utils.py", line 50, in load_model
|     return spacy.load(spacy_model_name, disable=["parser"])
|   File "/opt/venv/lib/python3.8/site-packages/spacy/__init__.py", line 50, in load
|     return util.load_model(
|   File "/opt/venv/lib/python3.8/site-packages/spacy/util.py", line 331, in load_model
|     raise IOError(Errors.E050.format(name=name))
| OSError: [E050] Can't find model 'en_core_web_lg'. It doesn't seem to be a Python package or a valid path to a data directory.

Inside the .env docker file:

RASA_X_VERSION=0.41.2
RASA_VERSION=2.7.2
RASA_X_DEMO_VERSION=0.41.2
RASA_TELEMETRY_ENABLED=true

I don’t know if i have to specify some other dependencies or what, help me please

@GiackV you need the en_core_web_lg model in the container

Oh that was clear, but how can i add it? From the little i have studied, i thought that SpaCy was already included in the {RASA_VERSION}-full container, but clearly i’m wrong.

Can you kindly explain how to do it, or link me some guide please?

@GiackV you are trying to install rasa x or rasa open source.

rasa-x

@GiackV are you able to install basic rasa x without spacy ?

yes, of course, i already have the rasa-x open on the browser, but the model can’t be loaded for the reason above

@GiackV Ok as config.yml looking for a model, can you manually install the en_core_web_lg ?

/etc/rasa

python -m spacy download en_core_web_sm

OR

pip install rasa[spacy]==1.1.4 (OR Latest)

you just need to install this and it will detect the model (I hope so)

@GiackV If this does not work, then I will guide you a trick on how you can install spacy using dockerfile and build using docker-compose.yml

I already tried this, but doesn’t work. I think that’s because it cannot insert the spacy_lg model in the docker container. I have to do something like adding the model installation in the container image, and build it

@GiackV

Now, try to follow these steps.

  1. Create the Dockerfile for spacy with all run commands (google you will find it)
  2. Build it using docker-compose.override.yml

everything will be done inside /etc/rasa

@GiackV have you checked the rasa docker hub with the Spacy tag for lg ? lg stand for?

@nik202 Ok, i try it. I should do these steps:

1.a. Create an empty dockerfile inside /etc/rasa

1.b. Find the actual rasa-x image for the version i need and paste it in the dockerfile

1.c. Add the RUN commands for Spacy (pip install rasa[spacy] && python -m spacy download en_ore_web_lg) and save

2.a. Build with docker build

2.b. Restart containers

is it right?

P.s. i checked, but there isn’t. LG stands for Large

@GiackV perfect :100: yeps you are a quick learner. Good luck! I believe you can do it easily! :slight_smile:

@nik202 finally i solved this. Thank you very much for your help.

I followed these steps:

  1. Move in /etc/rasa and create an empty file “Dockerfile”, insert the commands to install spacy with the model, for me was:
FROM rasa/rasa:2.7.2-full  
# you can choose any pre-existing docker-image from rasa, even rasa-x or rasa-sdk

# set privileges
USER root
# install the model you need
RUN pip install rasa[spacy] && python -m spacy download en_core_web_lg 
USER 1001
  1. build this new image, and assign a tag to it
sudo docker build -t rasa_spacy .
  1. open the docker-compose.yml file and substitute the new image you modified, in my case the name was: rasa_spacy:lastest, save and exit

  2. run the command sudo docker-compose up -d

@GiackV Great congratulations !

Please confirm with me that this issue related to Rasa Open Source or Rasa X (If Rasa X please channge the topic category) and I’d recommend to you to use atleast 2.8.1 > image for rasa.

Good Luck!

@nik202 it’s mostly related to rasa X, i change the topic category. I use the 2.7.2 because this model will be installed on a Pepper Robot which has inside that version of rasa, not depending on me ahah

@GiackV then it makes sense.

I am unable to use docker run command in my project created using rasa platform to get rasa /duckling

I installed containers for windows server 2019. Then installed docker desktop

Does rasa/ ducking require Linux environment?