Error loading yolov8 detector with opencv 4.6.0 cpp interface

[ERROR:0@0.025] global /home/…/dnn/src/onnx/onnx_importer.cpp(1018) handleNode DNN/ONNX:ERROR during processing node with 2 inputs and 2 outputs [split]:(onnx_node!/model.22/split)from domain=‘ai.onnx’ terminate called after throwing an instance of ‘cv::Exception’

what():OpenCV(4.6.0) /home/…/dnn/src/onnx/onnx_importer.cpp:1040:error:(-2 :unspecified error) in function ‘handleNode’

Node[Split@ai.onnx]:(onnx_node!/model.22/split) parse error:OpenCV(4.6.0) /home/…/dnn/src/layer/slice_layer.cpp:235:error:(-215 :Assertion failed)splits>0 && inpshape[axis_rw]%splits==0 in function ‘getMemoryShapes’

i am getting the above error when i am reading my yolov8 model trained on custom dataset saved as and then converted to best.onnx Net net=readNetFromONNX(“./best.onnx”)
i have tried downgrading its opset from 17 to 12 but i couldn’t go below 15 so i tried testing it on opset 15 but got the same error

when i am reading the same model in python i.e. cv2.dnn.readNetFromONNX(“./best.onnx”) i am getting no error

the input shape of my model is static [1,3,640,640]
opencv version:4.6.0
offline debian machine
cmake version 3.25.0


it was my first time asking questions on an online community forum and i wasn’t aware of crossposting and its downsides. So kindly look into my issue.