Getting error as Cuda Runtime (invalid argument)

Description

I am getting the following error when I executed the script. The script file is attached along with message posting.

[TensorRT] INTERNAL ERROR: [defaultAllocator.cpp::free::85] Error Code 1: Cuda Runtime (invalid argument)

Environment

The Jetson Nano board from NVIDIA
TensorRT Version: 8.0.1.6
GPU Type: GPU present on the Jetson Nano board
Nvidia Driver Version: -NA-
CUDA Version: -NA-
CUDNN Version: -NA-
Operating System + Version: Linux ubuntu 4.9.253-tegra #2 SMP PREEMPT Tue Nov 29 18:32:41 IST 2022 aarch64 aarch64 aarch64 GNU/Linux
Python Version (if applicable): 3.6
TensorFlow Version (if applicable): -NA-
PyTorch Version (if applicable): -NA-
Baremetal or Container (if container which image + tag): -NA-

Relevant Files

Files uploaded are
pytorch_tensorrt.py and resnet_engine_pytorch_fp16.trt

The file resnet_engine_pytorch_fp16.trt is created using trtexec command on the jetson nano from the onnx file resnet50_pytorch.onnx
The onnx model is created using the link which is present in the attached file link.txt
link.txt (185 Bytes)

The trtexec command is used as below
trtexec --onnx=resnet50_pytorch.onnx --saveEngine=resnet_engine_pytorch_fp16.trt --explicitBatch --inputIOFormats=fp16:chw --outputIOFormats=fp16:chw --fp16
resnet_engine_pytorch_fp16.trt (49.3 MB)
pytorch_to_tensorrt.py (322 Bytes)

Steps To Reproduce

  1. Place the file resnet_engine_pytorch_fp16.trt in the same directory where the script pytorch_tensorrt.py is present
  2. Execute the script with the command
    python3.6 pytorch_tensorrt.py

Please include:

  • Exact steps/commands to build your repro
  • Exact steps/commands to run your repro
  • Full traceback of errors encountered

Hi,

This looks like a Jetson issue. Please refer to the below samples in case useful.

For any further assistance, we will move this post to to Jetson related forum.

Thanks!

Thanks Aakanksha. I need to one more help, the link which you have provided makes use of importing the torch as
import torch
from torch2trt import torch2trt
May I know how to install the pytorch on the jetson nano board so that I won’t get any errors. Otherwise I get into fixing these issues.
I am doing all these activities as part of writing a Master’s thesis on “Accelerating DL Inference Performance On the Embedded IoT platform” . For this I have chosen Jetson Nano board. I have very limited free time as I am a working professional. It will be helpful if you arrange me a direct chatting with any NVIDIA engineer or direct email ID so that it will speed up my work.

Thanks and Regards

Nagaraj Trivedi

Hi,

You can follow the below document to install PyTorch on Nano.
The command is for Orin users. Please update it with JetPack 4.6.3 for the Nano.
https://docs.nvidia.com/deeplearning/frameworks/install-pytorch-jetson-platform/index.html

Thanks.

Hi AastaLLL, I have followed the steps explained in the link you have provided. But at the end it has thrown this error. May I know what could be the reason.

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in ./.local/lib/python3.6/site-packages (21.3.1)
Defaulting to user installation because normal site-packages is not writeable
ERROR: Invalid requirement: ‘LD_LIBRARY_PATH=/usr/lib/llvm-8/lib:/usr/local/cuda-10.2/lib64{LD_LIBRARY_PATH:+:}’
Hint: It looks like a path. File ‘LD_LIBRARY_PATH=/usr/lib/llvm-8/lib:/usr/local/cuda-10.2/lib64{LD_LIBRARY_PATH:+:}’ does not exist.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: protobuf in ./.local/lib/python3.6/site-packages (3.19.6)
Defaulting to user installation because normal site-packages is not writeable
ERROR: torch-2.0.0a0+fe05266f.nv23.04-cp38-cp38-linux_aarch64.whl is not a supported wheel on this platform.

Hi,

The command is for the JetPack 5 user.
Please update it based on your JetPack version.

For example:

$ python3 -m pip install --no-cache https://developer.download.nvidia.com/compute/redist/jp/v461/pytorch/torch-1.11.0a0+17540c5+nv22.01-cp36-cp36m-linux_aarch64.whl

Thanks.

Hi AastaLLL, thank you for the suggestion. It got installed. But I am facing one more issue that when I tried verifying using the command
python3

import torch
It gave a user warning
/home/mistral/.local/lib/python3.6/site-packages/torch/_masked/init.py:223: UserWarning: Failed to initialize NumPy: No module named ‘numpy.core._multiarray_umath’ (Triggered internally at /opt/package_build/pytorch/torch/csrc/utils/tensor_numpy.cpp:68.)
example_input = torch.tensor([[-3, -2, -1], [0, 1, 2]])

Will that be OK to ignore it OR do I need to install another version of numpy to be compatible with this.
Please let me know.

Hi,

Which NumPy have you installed?
Please try 1.19.4 for Jetson Nano.

$ pip3 install numpy==1.19.4

Thanks.

It installed the pytorch. After that I tried installing the torchversion required for it through the following steps. But it gives error while running the setup,py script as
OSError: libomp.so: cannot open shared object file: No such file or directory

Below are the commands executed to get above error. Also is there any any link to install the appropriate torchvision version?

sudo apt install -y libjpeg-dev zlib1g-dev
git clone --branch v0.11.1 GitHub - pytorch/vision: Datasets, Transforms and Models specific to Computer Vision torchvision
cd torchvision
sudo python3 setup.py install

After this I got the following error

Traceback (most recent call last):
File “setup.py”, line 14, in
import torch
File “/home/mistral/.local/lib/python3.6/site-packages/torch/init.py”, line 198, in
_load_global_deps()
File “/home/mistral/.local/lib/python3.6/site-packages/torch/init.py”, line 151, in _load_global_deps
ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
File “/usr/lib/python3.6/ctypes/init.py”, line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: libomp.so: cannot open shared object file: No such file or directory

Hi,

Please check the below topic for more info:

Thanks.

OK. Let me try and get back to you.

Please refer to this tutorial for torch and torchvision installation

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