diff --git a/docs/deployments/inferentia.md b/docs/deployments/inferentia.md index 4254533102..ad917c75cf 100644 --- a/docs/deployments/inferentia.md +++ b/docs/deployments/inferentia.md @@ -44,7 +44,8 @@ import tensorflow.neuron as tfn tfn.saved_model.compile( model_dir, compiled_model_dir, - compiler_args=["--num-neuroncores", "1"] + batch_size, + compiler_args=["--num-neuroncores", "1"], ) ``` @@ -54,6 +55,7 @@ Here is an example of compiling a PyTorch model for Inferentia: import torch_neuron, torch model.eval() +example_input = torch.zeros([batch_size] + input_shape, dtype=torch.float32) model_neuron = torch.neuron.trace( model, example_inputs=[example_input], diff --git a/examples/pytorch/image-classifier-resnet50/README.md b/examples/pytorch/image-classifier-resnet50/README.md index 5b34f93fd6..efa0505f8c 100644 --- a/examples/pytorch/image-classifier-resnet50/README.md +++ b/examples/pytorch/image-classifier-resnet50/README.md @@ -43,7 +43,9 @@ This example deploys models that we have built and uploaded to a public S3 bucke Run the following command to install the dependencies required for the [generate_resnet50_models.ipynb](generate_resnet50_models.ipynb) notebook: ```bash -pip install neuron-cc==1.0.9410.0+6008239556 torch-neuron==1.0.825.0 +pip install --extra-index-url=https://pip.repos.neuron.amazonaws.com \ + neuron-cc==1.0.9410.0+6008239556 \ + torch-neuron==1.0.825.0 ``` Also, `torchvision` has to be installed, but without any dependencies: diff --git a/examples/pytorch/image-classifier-resnet50/generate_resnet50_models.ipynb b/examples/pytorch/image-classifier-resnet50/generate_resnet50_models.ipynb index 7c6fe44cec..6fd919ce22 100644 --- a/examples/pytorch/image-classifier-resnet50/generate_resnet50_models.ipynb +++ b/examples/pytorch/image-classifier-resnet50/generate_resnet50_models.ipynb @@ -67,7 +67,8 @@ ], "source": [ "model.eval()\n", - "image = torch.zeros([1, 3, 224, 224], dtype=torch.float32)\n", + "batch_size = 1\n", + "image = torch.zeros([batch_size, 3, 224, 224], dtype=torch.float32)\n", "model_neuron = torch.neuron.trace(model, example_inputs=[image], compiler_args=[\"--num-neuroncores\", \"2\"])" ] }, diff --git a/examples/tensorflow/image-classifier-resnet50/README.md b/examples/tensorflow/image-classifier-resnet50/README.md index 6122fb81cd..e34be5c043 100644 --- a/examples/tensorflow/image-classifier-resnet50/README.md +++ b/examples/tensorflow/image-classifier-resnet50/README.md @@ -84,7 +84,9 @@ This example deploys models that we have built and uploaded to a public S3 bucke Run the following command to install the dependencies required for the [generate_resnet50_models.ipynb](generate_resnet50_models.ipynb) notebook: ```bash -pip install neuron-cc==1.0.9410.0+6008239556 tensorflow-neuron==1.15.0.1.0.1333.0 +pip install --extra-index-url=https://pip.repos.neuron.amazonaws.com \ + neuron-cc==1.0.9410.0+6008239556 \ + tensorflow-neuron==1.15.0.1.0.1333.0 ``` The [generate_resnet50_models.ipynb](generate_resnet50_models.ipynb) notebook will generate 2 SavedModels. One will be saved in the `resnet50` directory which can be run on GPU or on CPU and another in the `resnet50_neuron` directory which can only be run on `inf1` instances. diff --git a/examples/tensorflow/image-classifier-resnet50/generate_resnet50_models.ipynb b/examples/tensorflow/image-classifier-resnet50/generate_resnet50_models.ipynb index 6e30f2ab5c..29a9a7d287 100644 --- a/examples/tensorflow/image-classifier-resnet50/generate_resnet50_models.ipynb +++ b/examples/tensorflow/image-classifier-resnet50/generate_resnet50_models.ipynb @@ -149,7 +149,8 @@ ], "source": [ "compiler_args = ['--static-weights', '--num-neuroncores', '1']\n", - "tfn.saved_model.compile(model_dir, compiled_model_dir)" + "batch_size = 1\n", + "tfn.saved_model.compile(model_dir, compiled_model_dir, batch_size)" ] } ],