# Uploading ML Models into Elasticsearch

**URL:** <https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195>\
**Category:** Kibana\
**Tags:** elastic-stack-machine-learning\
**Created:** [July 12, 2023, 9:24am UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195 "2023-07-12T09:24:04Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksaimohan2k](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@ksaimohan2k](https://discuss.elastic.co/u/ksaimohan2k)\
**Post date:** [July 12, 2023, 9:24am UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/1 "2023-07-12T09:24:04Z")

</div>

I am trying to upload ML Model into elasticsearch using the eland script provided in the documentation.

Installed Python, eland & Pytorch but still unable to upload.  
python version : Python 3.7.9  
Eland version : 8.3.0  
torch version : 1.11.0

Below is the script i am executing  
`eland_import_hub_model --url http://localhost:9200/ --hub-model-id openai/clip-vit-large-patch14 --task-type ner --start`

But facing this error 'eland\_import\_hub\_model' is not recognized as an internal or external command,operable program or batch file.

Thanks

---

<div class="post-metadata">

**Author:** ![joshdevins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdevins/32/62865_2.png) [@joshdevins](https://discuss.elastic.co/u/joshdevins)\
**Post date:** [July 12, 2023, 10:23am UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/2 "2023-07-12T10:23:09Z")

</div>

Hey @ksaimohan2k glad to hear you're interested in uploading models with eland! It sounds like the installed eland and `eland_import_hub_model` script is not being found on you system. Are you on Windows or macOS or Linux? I'd recommend trying out the Docker approach as well, as it's a bit more reliable across various operating systems.

See here for instructions: [GitHub - elastic/eland: Python Client and Toolkit for DataFrames, Big Data, Machine Learning and ETL in Elasticsearch](https://github.com/elastic/eland#docker)

---

<div class="post-metadata">

**Author:** ![ksaimohan2k](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@ksaimohan2k](https://discuss.elastic.co/u/ksaimohan2k)\
**Post date:** [July 12, 2023, 10:27am UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/3 "2023-07-12T10:27:21Z")

</div>

Thank you for the quick response @joshdevins. I am actually working on windows OS.

---

<div class="post-metadata">

**Author:** ![ksaimohan2k](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@ksaimohan2k](https://discuss.elastic.co/u/ksaimohan2k)\
**Post date:** [July 12, 2023, 11:45am UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/4 "2023-07-12T11:45:08Z")

</div>

Hi @joshdevins even in docker i am facing the same issue i am able to see in folders within path that eland\_import\_hub\_model existed but when i am execuitng the command facing the error

```auto
C:\Users\SaiMohan\eland\bin>docker run -it --rm --network host eland_import_hub_model --url http://localhost:9200/ --hub-model-id openai/clip-vit-large-patch14 --task-type ner --start
Unable to find image 'eland_import_hub_model:latest' locally
docker: Error response from daemon: pull access denied for eland_import_hub_model, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

```

---

<div class="post-metadata">

**Author:** ![joshdevins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdevins/32/62865_2.png) [@joshdevins](https://discuss.elastic.co/u/joshdevins)\
**Post date:** [July 12, 2023, 12:55pm UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/5 "2023-07-12T12:55:13Z")

</div>

Hey @ksaimohan2k I'm sorry for the difficulties you're facing. We acknowledge that the current process is a bit complicated and are working hard to improve the tools for model upload.

I believe the original problem you are encountering might be due to a known [bug we have with eland on Windows](https://github.com/elastic/eland/issues/551). If you subscribe to that GitHub issue, you will get notifications about fixes.

For Docker, you have to make sure you build the container first:

```auto
$ docker build -t elastic/eland .

```

Was this successful?

---

<div class="post-metadata">

**Author:** ![ksaimohan2k](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@ksaimohan2k](https://discuss.elastic.co/u/ksaimohan2k)\
**Post date:** [July 12, 2023, 1:07pm UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/6 "2023-07-12T13:07:40Z")

</div>

Yes, the build was successful. Sorry if I am wasting your time; I am a bit new to all this and am trying to catch up. Thank You for spending your valuable time.

1. I cloned the using git` git clone git@github.com:elastic/eland.git`
2. The i executed the command for build

```auto
cd /path-to-repository/eland
docker build -t elastic/eland .

```

After this I am getting little confused about below command like where to run it within cmd because running the container I am getting # prompt where I am facing issue.

```auto
 $ docker run -it --rm --network host \
    elastic/eland \
    eland_import_hub_model \
      --url http://host.docker.internal:9200/ \
      --hub-model-id elastic/distilbert-base-cased-finetuned-conll03-english \
      --task-type ner

```

Thanks for your concern and help @joshdevins .

---

<div class="post-metadata">

**Author:** ![joshdevins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdevins/32/62865_2.png) [@joshdevins](https://discuss.elastic.co/u/joshdevins)\
**Post date:** [July 12, 2023, 1:17pm UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/7 "2023-07-12T13:17:20Z")

</div>

Let's see if we can get you up and running!

The Docker container should be run from in the directory where you cloned eland. Don't include the `$` in the command to run though.

---

<div class="post-metadata">

**Author:** ![ksaimohan2k](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@ksaimohan2k](https://discuss.elastic.co/u/ksaimohan2k)\
**Post date:** [July 12, 2023, 1:37pm UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/8 "2023-07-12T13:37:42Z")

</div>

Hey @joshdevins I am running that command in directory where I cloned eland.  
Sorry if my syntax is bad I am new to docker. I am attaching below error for the reference.

 ![docker](https://us1.discourse-cdn.com/elastic/original/3X/3/0/304836090e0e01c0897a728c8691ff114fc6c17a.png)

Thanks for you time.

---

<div class="post-metadata">

**Author:** ![joshdevins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdevins/32/62865_2.png) [@joshdevins](https://discuss.elastic.co/u/joshdevins)\
**Post date:** [July 12, 2023, 1:40pm UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/9 "2023-07-12T13:40:56Z")

</div>

I think in Windows you have to remove the `\` that are separating lines in the Linux/macOS examples. If it's a Docker problem, then I'm afraid it'll be hard for me to debug remotely. I'd look around for the error string on Google and in Docker forums to see if you can get the container running.

---

<div class="post-metadata">

**Author:** ![ksaimohan2k](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@ksaimohan2k](https://discuss.elastic.co/u/ksaimohan2k)\
**Post date:** [July 12, 2023, 1:46pm UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/10 "2023-07-12T13:46:55Z")

</div>

I tried removing `\`

Its sating `/usr/bin/env: 'python\r': No such file or directory`

 ![eland error](https://us1.discourse-cdn.com/elastic/original/3X/9/6/963e27703ba2f4ccf352567dd0b37adcd76a5e90.png)

Thank You

---

<div class="post-metadata">

**Author:** ![joshdevins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdevins/32/62865_2.png) [@joshdevins](https://discuss.elastic.co/u/joshdevins)\
**Post date:** [July 12, 2023, 1:55pm UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/11 "2023-07-12T13:55:28Z")

</div>

Ok, this is helpful. I think this is a bug with running on Windows. It might be possible to just do this in two steps:

```auto
docker run -it --rm --network host elastic/eland

```

And then when you get dropped into the container and get the Linux prompt (the `#`), try the second part of the command:

```auto
eland_import_hub_model --url http://host.docker.internal:9200/ --hub-model-id elastic/distilbert-base-cased-finetuned-conll03-english --task-type ner

```

---

<div class="post-metadata">

**Author:** ![ksaimohan2k](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@ksaimohan2k](https://discuss.elastic.co/u/ksaimohan2k)\
**Post date:** [July 12, 2023, 2:02pm UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/12 "2023-07-12T14:02:42Z")

</div>

made the changes, still the error this error remains same. I even tried it in docker desktop terminal.

 ![Eland error 2](https://us1.discourse-cdn.com/elastic/original/3X/6/a/6a44de5f4d9416a44de2618e6a79c5b11efaa900.png)  
 ![eland error docker desktop](https://us1.discourse-cdn.com/elastic/original/3X/d/d/dd1e9808b38a287762c79ca9e6605f0efe85750e.png)

Thanks

---

<div class="post-metadata">

**Author:** ![joshdevins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdevins/32/62865_2.png) [@joshdevins](https://discuss.elastic.co/u/joshdevins)\
**Post date:** [July 12, 2023, 2:19pm UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/13 "2023-07-12T14:19:34Z")

</div>

Yeah that trailing `\r` appears to be the problem. This looks like a Windows/Linux incompatibility for some reason in the script. This is a bit odd as the script in git doesn't have that trailing `\r` character. I'm not sure how to explain how this ended up. I know this works on macOS and Linux, do you possibly have access to a different machine to run this command from?

I think you might have to otherwise wait until this other [bug](https://github.com/elastic/eland/issues/551) is fixed.

---

<div class="post-metadata">

**Author:** ![ksaimohan2k](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@ksaimohan2k](https://discuss.elastic.co/u/ksaimohan2k)\
**Post date:** [July 12, 2023, 2:34pm UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/14 "2023-07-12T14:34:01Z")

</div>

Thanks, @joshdevins, for the info. I will try it shortly with Other OS Machines.  
I will try to update you using this thread.

I am even thinking of alternative methods for importing models into Elasticsearch.

Thank you for actively participating. Thanks for your valuable time.

---

<div class="post-metadata">

**Author:** ![joshdevins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdevins/32/62865_2.png) [@joshdevins](https://discuss.elastic.co/u/joshdevins)\
**Post date:** [July 12, 2023, 3:50pm UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/15 "2023-07-12T15:50:06Z")

</div>

Happy to help. Unfortunately for now, you must use `eland` for uploads as it also prepares the model to be used in Elasticsearch and this can't be done in any other tool for now.

We definitely recognise the difficulties with `eland` so we hope to also have alternative model upload tools in the future.

---

<div class="post-metadata">

**Author:** ![ksaimohan2k](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@ksaimohan2k](https://discuss.elastic.co/u/ksaimohan2k)\
**Post date:** [July 13, 2023, 5:04am UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/16 "2023-07-13T05:04:09Z")

</div>

Let's hope a remedy comes soon. I'll test out tasks with various Operating Systems in the interim.

Thank you for your help @joshdevins

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 10, 2023, 5:04am UTC](https://discuss.elastic.co/t/uploading-ml-models-into-elasticsearch/338195/17 "2023-08-10T05:04:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
