HelloWorld2307 commited on
Commit
bddb894
·
verified ·
1 Parent(s): 995e681

Upload ops folder as ops_data

Browse files
ops_data/http_grpc/export_onnx.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+
4
+ class AddModel(nn.Module):
5
+ def forward(self, x1, x2):
6
+ return x1 + x2
7
+
8
+ model = AddModel()
9
+ x1 = torch.randn(1, 3)
10
+ x2 = torch.randn(1, 3)
11
+
12
+ torch.onnx.export(
13
+ model,
14
+ (x1, x2),
15
+ "add.onnx",
16
+ input_names=["x1", "x2"],
17
+ output_names=["y"],
18
+ dynamic_axes={
19
+ "x1": {0: "batch"},
20
+ "x2": {0: "batch"},
21
+ "y": {0: "batch"},
22
+ },
23
+ opset_version=18,
24
+ )
ops_data/http_grpc/model_repo/add/1/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2580354f1ff3b5aca7b1f8e7edd534ba499a31be7c86c83a63ee6d3cd6319976
3
+ size 1224
ops_data/http_grpc/model_repo/add/1/model.onnx.data ADDED
File without changes
ops_data/http_grpc/model_repo/add/config.pbtxt ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "add"
2
+ platform: "onnxruntime_onnx"
3
+ max_batch_size: 8
4
+
5
+ input [
6
+ {
7
+ name: "x1"
8
+ data_type: TYPE_FP32
9
+ dims: [3]
10
+ },
11
+ {
12
+ name: "x2"
13
+ data_type: TYPE_FP32
14
+ dims: [3]
15
+ }
16
+ ]
17
+
18
+ output [
19
+ {
20
+ name: "y"
21
+ data_type: TYPE_FP32
22
+ dims: [3]
23
+ }
24
+ ]
ops_data/http_grpc/run.sh ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ docker run --rm --gpus all \
2
+ -p8000:8000 \
3
+ -p8001:8001 \
4
+ -p8002:8002 \
5
+ -v $PWD/model_repo:/models \
6
+ nvcr.io/nvidia/tritonserver:25.04-py3 \
7
+ tritonserver --model-repository=/models
ops_data/test.ipynb ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 5,
6
+ "id": "35abefab",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stdout",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "[[5. 7. 9.]]\n"
14
+ ]
15
+ }
16
+ ],
17
+ "source": [
18
+ "import numpy as np\n",
19
+ "import tritonclient.grpc as grpcclient\n",
20
+ "\n",
21
+ "client = grpcclient.InferenceServerClient(\"localhost:8001\")\n",
22
+ "\n",
23
+ "x1 = np.array([[1,2,3]], dtype=np.float32)\n",
24
+ "x2 = np.array([[4,5,6]], dtype=np.float32)\n",
25
+ "\n",
26
+ "inputs = [\n",
27
+ " grpcclient.InferInput(\"x1\", x1.shape, \"FP32\"),\n",
28
+ " grpcclient.InferInput(\"x2\", x2.shape, \"FP32\"),\n",
29
+ "]\n",
30
+ "inputs[0].set_data_from_numpy(x1)\n",
31
+ "inputs[1].set_data_from_numpy(x2)\n",
32
+ "\n",
33
+ "outputs = [grpcclient.InferRequestedOutput(\"y\")]\n",
34
+ "\n",
35
+ "res = client.infer(\"add\", inputs, outputs=outputs)\n",
36
+ "print(res.as_numpy(\"y\"))"
37
+ ]
38
+ }
39
+ ],
40
+ "metadata": {
41
+ "kernelspec": {
42
+ "display_name": "deploy",
43
+ "language": "python",
44
+ "name": "python3"
45
+ },
46
+ "language_info": {
47
+ "codemirror_mode": {
48
+ "name": "ipython",
49
+ "version": 3
50
+ },
51
+ "file_extension": ".py",
52
+ "mimetype": "text/x-python",
53
+ "name": "python",
54
+ "nbconvert_exporter": "python",
55
+ "pygments_lexer": "ipython3",
56
+ "version": "3.12.12"
57
+ }
58
+ },
59
+ "nbformat": 4,
60
+ "nbformat_minor": 5
61
+ }