'Cannot load model, error initializing graph for DIETClassifier from docker-compose

https://github.com/RasaHQ/rasa/blob/main/docker/docker-compose.yml I cannot load my model using docker-compose, it is giving an initializing graph component for node 'run_DIET'

version: '3.0'

services:
  rasa:
    image: rasa/rasa:3.0.8-full
    networks: ['rasa-network']
    ports:
    - "5005:5005"
    volumes:
    - "./formbot/:/app/"
    environment:
      MPLCONFIGDIR: "/tmp/"
    command:
    - run
    - --enable-api  
    - --cors   
    - "*"  

  action_server:
    image: rasa/rasa-sdk:latest
    networks: ['rasa-network']
    ports:
    - "5055:5055"
    volumes:
    - "./formbot/actions:/app/actions"

  duckling:
    image: rasa/duckling:latest
    networks: ['rasa-network']
    ports:
    - "8000:8000"

networks: {rasa-network: {}}

here is the log

Attaching to test-doc_duckling_1, test-doc_action_server_1, test-doc_rasa_1
action_server_1  | 2022-02-13 05:39:25 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
action_server_1  | 2022-02-13 05:39:25 INFO     rasa_sdk.executor  - Registered function for 'validate_restaurant_form'.
action_server_1  | 2022-02-13 05:39:25 INFO     rasa_sdk.endpoint  - Action endpoint is up and running on http://0.0.0.0:5055
duckling_1       | Listening on http://0.0.0.0:8000
rasa_1           | 2022-02-13 05:39:28 INFO     root  - Starting Rasa server on http://0.0.0.0:5005
rasa_1           | 2022-02-13 05:39:30 INFO     rasa.core.processor  - Loading model models/20220212-205144-small-slider.tar.gz...
rasa_1           | 2022-02-13 05:39:30 ERROR    rasa.core.agent  - Could not load model due to Error initializing graph component for node 'run_DIETClassifier4'..
rasa_1           | 2022-02-13 05:39:30 INFO     root  - Rasa server is up and running.

issue reference: https://github.com/RasaHQ/rasa/issues/10883



Solution 1:[1]

The probable issue is the model file that would be referencing component dependencies from /tmp. and causing the model to go rogue when patched with prebuild containers (rasa/rasa:3.0.8-full containers)

As a workaround, we can fully train the model after cloning the workdir into prebuilt containers which generate altogether a new model with all its dependencies met

Adding the docker file

FROM rasa/rasa:3.0.6-full

RUN rasa init --no-prompt
USER root
WORKDIR /app
COPY . .

RUN rasa train
RUN chmod +x /app/scripts/*

ENTRYPOINT []

CMD /app/scripts/start_services.sh

and scripts/start_services.sh

rasa run --model /app/models --enable-api --cors "*" --debug \
        --endpoints /app/endpoints.yml \
        -p 8080

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Partho Ghosh