microsoft / microsoft/onnxruntime

Memcopy (Host->Device) very slow on TX2 with Jetpack 4.5

Open
#6,783 12 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

ep:CUDA platform:jetson
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

**Describe the bug**
A memcopy from CPU to GPU that apparently has to be done takes 1.44 seconds, where the total inference time for the computation is 1.60 seconds. This issue occurs on a Jetson TX2 with Jetpack 4.5 (Cuda 10.2, cuDNN 8.0), but does not take place on a Jetson TX2 with Jetpack 4.2.1 (Cuda 10.0, cuDNN 7.5.0): there the same memcopy only takes 50ms. This duration grows proportional to the batch size of the input.

This seems to be a bug in ONNXRuntime with newer CUDA/cuDNN versions.

I'm not sure what is being copied to GPU btw, or how to figure this out. I converted the model from Tensorflow 2.3 using tf2onnx.convert, and first copied the two inputs to the model to GPU using io_binding(), but this makes no difference in inference time, so I guess it's not the input that's being copied from CPU to GPU. If someone could explain how I do figure this out (and prevent it from happening if possible), that would also be much appreciated.

**Urgency**
None

**System information**
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 18.04.5 LTS on Jetpack 4.5
- ONNX Runtime installed from (source or binary): from source
- ONNX Runtime version: 1.7.0 (without TensorRT bindings)
- Python version: 3.6.9
- GCC/Compiler version (if compiling from source): 7.5.0
- CUDA/cuDNN version: CUDA 10.2.89 cuDNN 8.0.0.180
- GPU model and memory: Jetson TX2 8GB

**To Reproduce**
Run attached onnx.py on Jetpack 4.5 to reproduce issue.

onnxruntime_perf_test -e cuda -I ~/onnx/model.onnx -r 10 -t 10 also works, but because that batch size is set to 1, the issue is less clear.

**Expected behavior**
You would expect the memcopy to be not slower than on older Jetpack (CUDA/cuDNN) versions

**Additional attachments**
Attached a trace from both Jetpack 4.2.1 and Jetpack 4.5, the verbose log from Jetpack 4.5, the tf2onnx conversion log and the files to reproduce those traces.
[github issue.zip](https://github.com/microsoft/onnxruntime/files/6029316/github.issue.zip)

**Additional context**
The Tensorflow model is from https://github.com/alleveenstra/attentionocr where I removed the positional embedding generation using tf.eye because tf2onnx does not support this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.