I have a cuda (v4.2) program running under visual studio 2010, to which I pass various command line parameters. I want the host compiler to see the same parameters when I run through nsight (v2.2). I assume I have to do this via (right click project) -> nsight user settings->command line arguments, but haven't yet managed to find a syntax that doesn't crash nvcc. I'm assuming it's arranged around "--run-args " somehow?
** Clarification, after comment below:
Sure when you debug straight through VS, you enter your command arguments through the property pages/command arguments, and that all works fine. But through NSight, that gets ignored, so my question is, how to do it? My talk of compilers assumes that nsight runs up NVCC, which then invokes MSVC under the covers for non CUDA code. So I assume that NSight needs to pass any command line parameters down into VS, presumably via the options described above. Assuming all that is reasonable, I suspect I'm simply getting the syntax wrong inside "nsight user settings->command line arguments" and was wondering if anyone else has succeeded here. Clearer?
It is unclear if you are trying to pass command line arguments through nvcc to cl.exe or pass command line arguments to your application when it is launched through Visual Studio with the command Nsight CUDA Debugger (Nsight|Start CUDA Debugging).
To pass command line arguments to cl.exe when compiling a .cu file to cl.exe
In Solution Explorer Right click on the .cu file
Execute Properties command
In the "filename.cu" Property Pages
a. In the left pane Select "CUDA C/C++"\"Host"
b. Add parameters to pass to cl.exe in "Additional Compiler Options" or "Preprocessor Definitions"
Preprocessor definitions will go to both nvcc.exe and cl.exe.
Additional Compiler Options will be appended to -Xcompiler options.
To pass command line arguments to your application when it is launched using Nsight|Start CUDA Debugging
In Solution Explorer Right click on the project (make sure this is your startup project)
Execute Nsight User Properties command
In the "NVIDIA NSight User Settings: " dialog
a. In the left pane select "Launch"
b. In the right specify arguments in the field "Command line arguments".
These options will be passed to the application when you launch the application with (Nsight|Start CUDA Debugging).
To pass command line arguments to your application when it is launched using Debug|Start * Debugging
In Solution Explorer Right click on the project (make sure this is your startup project)
Execute the Properties command
In the " Property Pages" dialog
a. In the left pane select "Debugging"
b. In the right pane add arguments to the field "Command Arguments"
When editing project Properties and Nsight User Properties make sure to specify the Configuration and Platform at the top of the dialog.
Nsight VSE build system does not use the nvcc --run and --run-args options. If you launch using a Debug command your process will be launched by devenv.exe. If you launch using Nsight|Start CUDA Debugging or Nsight Analysis Tools your application will be launched by Nsight.Monitor.exe.
i would like to help but i am confused; you talk about passing run-time arguments to your host code under VS. then you say you want the compiler to see the same parameters. i think you dont mean compiler. build your project first in VS (using the Debug version of your build). (and I already compile my .cu into a ptx file so nvcc doesnt get invoked when i go into Nsight. ) Then this build runs when you invoke Nsight. I have not had to provide run time arguments. there is a place in the VS project under Debug to give command line arguments; maybe this is used when Nsight starts although i have my doubts. Also, there is the Nsight user -> command line arguments input you cite. I would think the latter is indeed the correct way to do it. perhaps your problem is that you need to fully build the project before you start Nsight.
Related
I've started a CUDA application in the new CLion 2020.1 version. Although I can compile and run it, I am not able to debug it, not even the host code. Specifically, debug does not stop at breakpoints, even though I am running the debug build. I'm not encountering this issue with running a regular C project in CLion 2020.1. I don't receive any error message of any kind. Here is my CMakeLists.txt file:
# Setup the CUDA compiler
set(CMAKE_CUDA_COMPILER /usr/local/cuda-10.2/bin/nvcc)
# Setup the host compiler
set(CMAKE_CUDA_HOST_COMPILER /usr/bin/g++-8)
# CMAKE minimum required version
cmake_minimum_required(VERSION 3.16)
project(PageRank_GPU CUDA)
set(CMAKE_CUDA_STANDARD 14)
add_executable(PageRank_GPU main.cu graph.cu graph.cuh vertex.cuh error.cuh parser.cu parser.cuh)
set_target_properties(
PageRank_GPU
PROPERTIES
CUDA_SEPARABLE_COMPILATION ON)
Reporting that the issue has disappeared after playing around in the project settings a bit. Specifically, under Build, Execution, Deployment then Toolchain, I set the C and C++ compilers to gcc-8 and g++-8 respectively (even though I am specifying the compiler in the CMakeLists.txt file) and under CMake, I set the toolchain to "Default" (the one I just modified) instead of "Use Default". After doing that, the debugger stops at breakpoints and I am able to step through my code. I don't understand what happened because, even after reverting the changes, I cannot make the problem re-appear.
I've successfully installed Cuda SDK and tested the compiler with an HelloWorld
Then I've opened Nsight and I've tried with the same code.
I got this answer " Launch Failed. Binary not found." Is this a problem of the compiler involved in Nsight?
Thank you
This is a known bug. We are aware of it and will try to fix it in one of our future releases.
You need to manually build the project at least once before starting the debug - this is needed for the debugger to be able to detect executable and setup all settings. Note that the debugger will automatically trigger the build on subsequent runs - when it already knows the executable and build configuration you are using..
I'we been writing some simple cuda program (I'm student so I need to practice), and the thing is I can compile it with nvcc from terminal (using Kubuntu 12.04LTS) and then execute it with optirun ./a.out (hardver is geforce gt 525m on dell inspiron) and everything works fine. The major problem is that I can't do anything from Nsight. When I try to start debug version of code the message is "Launch failed! Binaries not found!". I think it's about running command with optirun but I'm not sure. Any similar experiences? Thanks, for helping in advance folks. :)
As this was the first post I found when searching for "nsight optirun" I just wanted to wanted to write down the steps I took to make it working for me.
Go to Run -> Debug Configurations -> Debugger
Find the textbox for CUDA GDB executable (in my case it was set to "${cuda_bin}/cuda-gdb")
Prepend "optirun --no-xorg", in my case it was then "optirun --no-xorg ${cuda_bin}/cuda-gdb"
The "--no-xorg" option might not be required or even counterproductive if you have an OpenGL window as it prevents any of that to appear. For my scientific code however it is required as it prevents me from running into kernel timeouts.
Happy bug hunting.
We tested Nsight on Optimus systems without optirun - see "Install the cuda toolkit" in CUDA Toolkit Getting Started on using CUDA toolkit on the Optimus system. We have not tried optirun with Nsight EE.
If you still need to use optirun for debugging, you can try making a shell script that uses optirun to start cuda-gdb and set that shell script as cuda-gdb executable in the debug configuration properties.
The simplest thing to do is to run eclipse with optirun, that will also run your app properly.
I run code using nvcc command and it gave correct output but when I run the same code on the nsight eclipse it gave wrong output. Any one have any idea why is this behavior.
Finally I found there is problem in one of the array allocation.While the command line doesn't make any problem the nsight does.
Nsight EE builds the projects by generating make files based on the project settings and by invoking the OS make utility to build the project. It is using nvcc compiler found in the PATH but it relies on some newer options introduced in NVCC compiler 5.0 (that is a part of the same toolkit distribution).
Please do a clean rebuild in Nsight Eclipse - it will print out the command lines used to build your application. Then you can compare that command line with the one you use outside. Possible differences are:
Nsight specifies debug flags and optimization flag when building in debug and release modes.
By default, Nsight sets the new project to build for the hardware detected on your system. NVCC default is SM 1.0.
Make sure the compiler used by Nsight and from the command line are one and the same. It is possible that you have different compilers (e.g. 4.x and 5.0) installed on your system that may generate a slightly different code.
In any case, it is likely your code has some bug that manifests itself under different compilation settings. I would recommend running CUDA memcheck on you program to ensure there is no hidden bugs.
I'm using Cuda 5.0 with two gpu cards on Ubuntu 11.10 with Nsight Eclipse.
When I try to debug a a program from in Eclipse I get
Error in final launch sequence
Failed to execute MI command:
source .cuda-gdbinit
Error message from debugger back end:
.cuda-gdbinit: No such file or directory.
.cuda-gdbinit: No such file or directory.
I looked into Eclipse debug configuration, and I have
GDB debugger: cuda-gdb
GDB command file: .cuda-gdbinit
No where on my system is the file .cuda-gdbinit.
Should I create it? If so, where and with which content?
Is there something wrong with my cuda-gdb setup?
This message is harmless. What Nsight does is explicitly instructs cuda-gdb to read .cuda-gdbinit when starting debug session to pick up any custom settings user might have. It is perfectly fine not to have that file.
To prevent Eclipse CDT / nsight from tying to load .cuda-gdbint (which you can safely do as other answers suggest), you must remove it from the "GDB command file" associated with your run/debug configuration.
To do that,
Using the menus, go to Run | Debug Configurations
Select the Run/Debug/etc configuration for which you're getting the error message
In the multi-tabbed section, select the Debugger tab
In the sub-multi-tabbed section, select Main
You should now see a GDB Command File text box. Clear it.