Deploy Inference Server on NVIDIA JETSON

I am trying to deploy Inference server on NVIDIA Jetson

I am using reComputer Industrial J3011 Orin Nano 8GB.

Here is my project
Workspace: ARIES14
Project ID : pcba-5ohq1

Inference Server on my NVDIA Jetson is up and run using docker.

OAK-D Pro connected to J3011 via USB

Here is my Python code


import depthai as dai
import cv2
import requests
import numpy as np

ROBOFLOW_API_KEY = “tDJFy0d7a2nvfhwu8tdT”

ROBOFLOW_MODEL_URL = “http://localhost:9001/pcba-5ohq1/1

def process_frame_with_roboflow(frame):

retval,buffer = cv2.imencode(".jpg", frame)
if not retval:
    print("Failed to encode frame")
    return None

response = requests.post(
    ROBOFLOW_MODEL_URL,
    params={"api_key": ROBOFLOW_API_KEY},
    files={"file": buffer.tobytes()},
    headers={"accept": "application/json"}
)
return response.json()

def draw_predictions(frame, predictions):

if not predictions or 'predictions' not in predictions:
    return frame

for pred in predictions['predictions']:
    x, y, width, height = int(pred['x']),int(pred['y']), int(pred['width']), int(pred['height'])
    confidence = pred['confidence']
    label = pred['class']

    start_point = (x-width // 2, y-height // 2)
    end_point = (x+width // 2 , y+height // 2)
    color = (0, 255, 0)
    cv2.rectangle(frame, start_point, end_point, color, 2)
    cv2.putText(frame, f"{label}: {confidence:.2f}", (x-width // 2, y-height // 2 - 10),cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
return frame

pipeline = dai.Pipeline()

cam_rgb = pipeline.create(dai.node.ColorCamera)
cam_rgb.setPreviewSize(640 , 480)
cam_rgb.setInterleaved(False)
cam_rgb.setFps(30)

xout_rgb = pipeline.create(dai.node.XLinkOut)
xout_rgb.setStreamName(“rgb”)
cam_rgb.preview.link(xout_rgb.input)

with dai.Device(pipeline) as device:

print("starting stream... press 'q' to quit")
queue = device.getOutputQueue(name='rgb', maxSize=4, blocking=False)

while True:

    frame_data = queue.get()
    frame = frame_data.getCvFrame()

    predictions = process_frame_with_roboflow(frame)

    frame = draw_predictions(frame, predictions)

    cv2.imshow("OAK-D Stream with Roboflow Inference", frame)

    if cv2.waitKey(1) & 0xFF == ord("q"):
        break

cv2.destroyAllwindows()


It is working fine if Inference server is set to “detect.roboflow.com
But there will be an error if it is set to “localhost:9001”

[ error on client]
starting stream… press ‘q’ to quit
Traceback (most recent call last):
File “oakd.py”, line 64, in
predictions = process_frame_with_roboflow(frame)
File “oakd.py”, line 23, in process_frame_with_roboflow
return response.json()
File “/usr/lib/python3/dist-packages/requests/models.py”, line 897, in json
return complexjson.loads(self.text, **kwargs)
File “/usr/lib/python3/dist-packages/simplejson/init.py”, line 518, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3/dist-packages/simplejson/decoder.py”, line 370, in decode
obj, end = self.raw_decode(s)
File “/usr/lib/python3/dist-packages/simplejson/decoder.py”, line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

[ Error from Inference Server]
TypeError: req.body.replace is not a function
at transformImageBody (/inference-server/server/index.js:323:26)
at Layer.handle [as handle_request] (/inference-server/server/node_modules/express/lib/router/layer.js:95:5)
at next (/inference-server/server/node_modules/express/lib/router/route.js:144:13)
at Route.dispatch (/inference-server/server/node_modules/express/lib/router/route.js:114:3)
at Layer.handle [as handle_request] (/inference-server/server/node_modules/express/lib/router/layer.js:95:5)
at /inference-server/server/node_modules/express/lib/router/index.js:284:15
at param (/inference-server/server/node_modules/express/lib/router/index.js:365:14)
at param (/inference-server/server/node_modules/express/lib/router/index.js:376:14)
at param (/inference-server/server/node_modules/express/lib/router/index.js:376:14)
at Function.process_params (/inference-server/server/node_modules/express/lib/router/index.js:421:3)

Hi @Aries14. Sounds like there are two potential issues here:

  1. There’s a problem with the Roboflow Inference server. If you’re running an unsupported JetPack version, this is a possibility.
  2. There’s an issue with the OAK-D Pro integration.

My recommendation would be to decouple the two potential problems here, and test individually. Start with the local Inference Server. Either download or generate an image and infer on it (localhost:9001). If that works, you can further probe the OAK-D Pro integration (You can refer to our docs: Luxonis OAK-D - Deploy a Custom Object Detection Model with Depth)

If you’re having problems with the OAK-D Pro, consider using an easier camera option, such as a simple, well-supported USB camera or even a camera with RTSP support (There’s a lot of great options for cheap).

OAK-D Pro integration is not the issue. It works well with Roboflow and J3011 , it has been tested .

I suspect the local inference server issue. My J3011 has JetPack 5.1.2 installed.

I conduct 2 simple tests using jpg image

  1. base64 test2.jpg | curl -d @- “https://detect.roboflow.com/pcba-5ohq1/1?api_key=tDJFy0d7a2nvfhwu8tdT

[RESULT]
{“inference_id”:“b4515d51-b9be-4fb1-9837-c67f35586f9e”,“time”:0.03413285399983579,“image”:{“width”:395,“height”:480},“predictions”:[{“x”:349.5,“y”:124.5,“width”:91.0,“height”:211.0,“confidence”:0.7433829307556152,“class”:“Grape”,“class_id”:0,“detection_id”:“fef07a6c-0966-4066-8455-10452b224c91”},{“x”:317.0,“y”:398.0,“width”:154.0,“height”:164.0,“confidence”:0.555861234664917,“class”:“Grape”,“class_id”:0,“detection_id”:“27397cd6-d37f-4521-8a74-53203b45cb2c”}]}

  1. base64 test2.jpg | curl -d @- “http://localhost:9001/pcba-5ohq1/1?api_key=tDJFy0d7a2nvfhwu8tdT

[RESULT]
<< no result >>

[Local inference Server log]

Downloading weights for pcba-5ohq1/1
requesting from roboflow server…
Weights downloaded in 1.73 seconds
Initializing model…
2024-12-13 23:21:50.091513: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7
2024-12-13 23:56:06.563623: W tensorflow/stream_executor/cuda/redzone_allocator.cc:312] Internal: ptxas exited with non-zero error code 65280, output: ptxas fatal : Value ‘sm_87’ is not defined for option ‘gpu-name’

Relying on driver to perform ptx compilation. This message will be only logged once.
2024-12-13 23:56:07.628370: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10.0
2024-12-13 23:59:19.580741: E tensorflow/stream_executor/cuda/cuda_blas.cc:428] failed to run cuBLAS routine: CUBLAS_STATUS_EXECUTION_FAILED
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
Error: Invalid TF_Status: 13
Message: Blas SGEMM launch failed : m=25600, n=32, k=32
at NodeJSKernelBackend.executeSingleOutput (/inference-server/server/node_modules/@roboflow/tfjs-jetson/dist/nodejs_kernel_backend.js:209:43)
at Object.conv2dImpl (/inference-server/server/node_modules/@roboflow/tfjs-jetson/dist/kernels/Conv2D.js:66:20)
at Object.kernelFunc (/inference-server/server/node_modules/@roboflow/tfjs-jetson/dist/kernels/FusedConv2D.js:30:31)
at kernelFunc (/inference-server/server/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4592:32)
at /inference-server/server/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4652:27
at Engine.scopedRun (/inference-server/server/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4457:23)
at Engine.runKernelFunc (/inference-server/server/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4648:14)
at Engine.runKernel (/inference-server/server/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4521:21)
at /inference-server/server/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:23547:30
at forwardFunc (/inference-server/server/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:5092:25)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.