System Profiler: Fail in adding NVTX to my application

I did well upto connecting host computer with Jetson TX2 target board (Ubuntu) using Tegra System Profiler (ver 4.0).
I want to add NVTX(Tools Extensions) to improve readability of analysis, but it’s not easy for me.

Seeing a warning message “NVTX_INJECTION64_PATH variable is missing from the environment variables of the process. Make sure the process was appropriately launched.” from Diagnostics Summary, I tried to add the variable in .bashrc or my app code using putenv(), but they all resulted in the same fail.

Finally I have found one method to add NVTX_INJECTION64_PATH env variable to my app.
It is launching my app from the profiler rather than attaching already launched app.

But my app needs root privilege, so when launched without su, it stops right away after it starts.
(But env variable missing warning as above seems not found at this time.)
So after several web searching, I have tried ““echo nvidia | sudo -S myappname” myappargs” but it fails before startup.

Could anybody help me with this problem?

Hi lunalovre,

You want to collect NVTX traces and your application needs to run as root. You have two options:

  • Launch your application through the GUI. It will automatically launch it with the required environment variables.
    1. Select the "Attach or launch" mode. Make sure that your application is not already running on the target, otherwise the profiler will attach to the running process. Note that the profiler does not kill your application after the collection terminates so beware of running processes from previous profiling sessions.
    2. Check the "Collect NVTX trace" checkbox.
    3. Check the "Launch as root" checkbox.
  • Launch your application manually and attach through the GUI.
    1. Select the "Attach only" or "Attach by PID" mode.
    2. Make sure to launch your application as root with the following environment variables. Assuming your application is 64-bit.
      1. LD_PRELOAD="/opt/nvidia/nsight_systems/"
  • There are multiple ways to launch your application as root with the required environment but you can use the following trick. Again, note that this is not necessary if you launch the application through the GUI.
    $ sudo sh -c "LD_PRELOAD=/opt/nvidia/nsight_systems/ QUADD_INJECTION_PROXY=NVTX <Application> <Arguments>"

    Hi afroger,

    Thank you for your help.

    Owing to you, I have had some gain, as well as some questions.

    I could not find “Launch as root” checkbox in my tegra system profiler.
    Perhaps does nsight system have the checkbox?

    Anyway I followed your second guide for attaching to already launched application.
    But in my circumstance, I tried a little different one like this.

    $ sudo sh -c "NVTX_INJECTION64_PATH=/opt/nvidia/system_profiler/ "

    By doing this, I could add NVTX on my analysis.

    Thank you again!

    Sorry for the delay, I completely forgot to reply. Which version of Nsight Systems are you using? The latest version available for Jetson and Drive platforms is 2019.3.4. With this version of the tool, you will find the ‘Launch as root’ checkbox under the ‘Include child processes’ checkbox.