Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/deployments/inferentia.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
```

Expand All @@ -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],
Expand Down
4 changes: 3 additions & 1 deletion examples/pytorch/image-classifier-resnet50/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\"])"
]
},
Expand Down
4 changes: 3 additions & 1 deletion examples/tensorflow/image-classifier-resnet50/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
}
],
Expand Down