Skip to content

Commit af7ee3d

Browse files
committedMar 9, 2024
Add note about gpu placement + simplify call to model->run
1 parent 0933c7d commit af7ee3d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed
 

‎examples/cpp/aot_inductor/bert/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ This example uses AOTInductor to compile the [google-bert/bert-base-uncased](htt
22

33
Then, this example loads model and runs prediction using libtorch. The handler C++ source code for this examples can be found [here](src).
44

5+
**Note**: Please note that due to an issue in Pytorch 2.2.1 the AOTInductor model can not be placed on a specific GPU through the API. This issue is resolved in the PT 2.3 nightlies. Please install the nightlies if you want to run multiple model worker on different GPUs.
6+
57
### Setup
68
1. Follow the instructions in [README.md](../../../../cpp/README.md) to build the TorchServe C++ backend.
79

‎examples/cpp/aot_inductor/bert/src/bert_handler.cc

+1-5
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,8 @@ c10::IValue BertCppHandler::Inference(
157157
} else {
158158
runner = std::static_pointer_cast<torch::inductor::AOTIModelContainerRunnerCpu>(model);
159159
}
160-
#if TORCH_VERSION_MAJOR == 2 && TORCH_VERSION_MINOR == 2
161-
auto batch_output_tensor_vector = runner->run(inputs.toTensorVector());
162-
#else
163-
std::vector<torch::Tensor> tmp = inputs.toTensorVector();
160+
auto tmp = inputs.toTensorVector();
164161
auto batch_output_tensor_vector = runner->run(tmp);
165-
#endif
166162
return c10::IValue(batch_output_tensor_vector[0]);
167163
} catch (std::runtime_error& e) {
168164
TS_LOG(ERROR, e.what());

‎examples/cpp/aot_inductor/resnet/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
This example uses AOTInductor to compile the Resnet50 into an so file which is then executed using libtorch.
22
The handler C++ source code for this examples can be found [here](src).
33

4+
**Note**: Please note that due to an issue in Pytorch 2.2.1 the AOTInductor model can not be placed on a specific GPU through the API. This issue is resolved in the PT 2.3 nightlies. Please install the nightlies if you want to run multiple model worker on different GPUs.
5+
46
### Setup
57
1. Follow the instructions in [README.md](../../../../cpp/README.md) to build the TorchServe C++ backend.
68

0 commit comments

Comments
 (0)