Skip to content

Commit 8a9917a

Browse files
RobertLuciandeliahu
authored andcommitted
Add missing extra-index-url & improve Inf docs (#1170)
(cherry picked from commit 7b99d88)
1 parent 10becbb commit 8a9917a

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

docs/deployments/inferentia.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ import tensorflow.neuron as tfn
4242
tfn.saved_model.compile(
4343
model_dir,
4444
compiled_model_dir,
45-
compiler_args=["--num-neuroncores", "1"]
45+
batch_size,
46+
compiler_args=["--num-neuroncores", "1"],
4647
)
4748
```
4849

@@ -52,6 +53,7 @@ Here is an example of compiling a PyTorch model for Inferentia:
5253
import torch_neuron, torch
5354

5455
model.eval()
56+
example_input = torch.zeros([batch_size] + input_shape, dtype=torch.float32)
5557
model_neuron = torch.neuron.trace(
5658
model,
5759
example_inputs=[example_input],

examples/pytorch/image-classifier-resnet50/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ This example deploys models that we have built and uploaded to a public S3 bucke
4343
Run the following command to install the dependencies required for the [generate_resnet50_models.ipynb](generate_resnet50_models.ipynb) notebook:
4444

4545
```bash
46-
pip install neuron-cc==1.0.9410.0+6008239556 torch-neuron==1.0.825.0
46+
pip install --extra-index-url=https://pip.repos.neuron.amazonaws.com \
47+
neuron-cc==1.0.9410.0+6008239556 \
48+
torch-neuron==1.0.825.0
4749
```
4850

4951
Also, `torchvision` has to be installed, but without any dependencies:

examples/pytorch/image-classifier-resnet50/generate_resnet50_models.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
],
6868
"source": [
6969
"model.eval()\n",
70-
"image = torch.zeros([1, 3, 224, 224], dtype=torch.float32)\n",
70+
"batch_size = 1\n",
71+
"image = torch.zeros([batch_size, 3, 224, 224], dtype=torch.float32)\n",
7172
"model_neuron = torch.neuron.trace(model, example_inputs=[image], compiler_args=[\"--num-neuroncores\", \"2\"])"
7273
]
7374
},

examples/tensorflow/image-classifier-resnet50/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ This example deploys models that we have built and uploaded to a public S3 bucke
8484
Run the following command to install the dependencies required for the [generate_resnet50_models.ipynb](generate_resnet50_models.ipynb) notebook:
8585
8686
```bash
87-
pip install neuron-cc==1.0.9410.0+6008239556 tensorflow-neuron==1.15.0.1.0.1333.0
87+
pip install --extra-index-url=https://pip.repos.neuron.amazonaws.com \
88+
neuron-cc==1.0.9410.0+6008239556 \
89+
tensorflow-neuron==1.15.0.1.0.1333.0
8890
```
8991
9092
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.

examples/tensorflow/image-classifier-resnet50/generate_resnet50_models.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@
149149
],
150150
"source": [
151151
"compiler_args = ['--static-weights', '--num-neuroncores', '1']\n",
152-
"tfn.saved_model.compile(model_dir, compiled_model_dir)"
152+
"batch_size = 1\n",
153+
"tfn.saved_model.compile(model_dir, compiled_model_dir, batch_size)"
153154
]
154155
}
155156
],

0 commit comments

Comments
 (0)