TorchServe AWS EC2 Deployment Error

AllenAkhaumere: <p>Hello, I’m getting the following error message:<br>
<em><strong>start java frontend failed: (&lt;class ‘NotADirectoryError’&gt;, NotADirectoryError(20, ‘Not a directory’), &lt;traceback object at 0x7f972aa7ad20&gt;)</strong></em>, while trying to start the torchserve serve on AWS EC2, using the following command:</p>
<p><em><strong>torchserve --start --model-store model_store --models densenet161=densenet161.mar</strong></em></p>
<p><strong>W</strong>hat am I doing wrong?<br>
Thanks</p>

ptrblck: <p>Based on the error message a directory doesn’t exist. I guess <code>model_store</code> might be the one, so make sure you’ve created it before executing <code>torchserve</code>.</p>

AllenAkhaumere: <p>Thanks for the respones.<br>
These are the steps I used.</p>
<p>Step 1<br>
<strong>mkdir torchserve-examples</strong><br>
<strong>cd torchserve-examples</strong><br>
<strong>git clone <a href="https://github.com/pytorch/serve.git" rel="noopener nofollow ugc">https://github.com/pytorch/serve.git</a></strong></p>
<p>Step 2<br>
<strong>wget <a href="https://download.pytorch.org/models/densenet161-8d451a50.pth" rel="noopener nofollow ugc">https://download.pytorch.org/models/densenet161-8d451a50.pth</a></strong></p>
<p>Step 3<br>
*<em>torch-model-archiver --model-name densenet161 *</em><br>
*<em>–version 1.0 --model-file serve/examples/image_classifier/densenet_161/model.py *</em><br>
*<em>–serialized-file densenet161-8d451a50.pth *</em><br>
*<em>–extra-files serve/examples/image_classifier/index_to_name.json *</em><br>
<strong>–handler image_classifier</strong></p>
<p>Step 4<br>
<strong>mkdir model_store</strong><br>
<strong>mv densenet161.mar model_store/</strong><br>
<strong>torchserve --start --model-store model_store --models densenet161=densenet161.mar</strong></p>
<p>Step 1 to 3 executed well. Just the last command in step 4 gives me issues.</p>
<p>This is first time I’m using AWS for a project like this. I really don’t know what I’m wrong.<br>
What should I do please.</p>

garner1: <p>Hi, I am facing a similar problem. The model_store directory is created but I get:<br>
<code>start java frontend failed: (&lt;class 'NotADirectoryError'&gt;, NotADirectoryError(20, 'Not a directory'), &lt;traceback object at 0x7feaf4cafb40&gt;)</code></p>

ptrblck: <p>The <code>NotADirectoryError</code> suggests that the used path isn’t pointing to a valid directory, so you could check it first via e.g. <code>os.path.isdir(PATH)</code>.</p>

ArturoDeza: <p>I still have the same problem as <a class="mention" href="/u/garner1">@garner1</a> and <a class="mention" href="/u/allenakhaumere">@AllenAkhaumere</a> . It seems like the problem has not been solved yet.</p>

espoirMur: <p>Same problem here. I have the model_store folder installed.</p>

espoirMur: <p>In more context, when I add call the command with a folder that does not exists, I get the following error:</p>
<p><code>--model-store directory not found: model_server.</code></p>
<p>But when I call the command with a folder that exists and contains the file, the error is different.</p>
<blockquote>
<p>start java frontend failed: (&lt;class ‘NotADirectoryError’&gt;, NotADirectoryError(20, ‘Not a directory’), &lt;traceback object at 0x10bab05c0&gt;)</p>
</blockquote>

espoirMur: <p>Seem to be a permission issue, I tried to run the command with sudo and got it solved.</p>
<p>Thanks to ChatGPT.</p>