What are the exact steps to run a .cu sample program? I found a sample application called vectorAdd and I don't really know how to compile and run it. The net says,
nvcc -o a.out vectorAdd.cu
./a.out
will do the job but I am getting an error
nvcc command not found
What should I be doing? PS: I am using Ubuntu 16.04, ARM
Open the terminal and type:
This will open .bashrc for editing. Add the following to the end of your .bashrc file.
This sets your PATH variable to the existing PATH plus what you add to the end.
Run
source ~/.bashrc
when in the home directory to reload the configuration for your session.Then type
nvcc
to run it.First read the Ubuntu sections on your CUDA Installation Guide: e.g. https://docs.google.com/viewer?url=https%3A%2F%2Fdocs.nvidia.com%2Fcuda%2Fpdf%2FCUDA_Installation_Guide_Linux.pdf&pdf=true
The recommendations in chapter 6 on setting the environment variables PATH and LD_LIBRARY_PATH indicate your cuda additions should be at the beginning of the existing PATH. This allows you to override the system g++ or gcc with an older version by simply adding links to the ...cuda/bin to the version you want. The last thing you want to do is change a system default compiler -- one which may not successfully be able to update your video driver when a kernel update occurs. If everything you do may use the old compiler, go ahead and modify your PATH setup in your .profile, so every login your cuda path gets set up. If you only want your CUDA work to use the old compiler, put the PATH, LD_LIBRARY_PATH modifications into a script to source when you want to.
The distributed samples are not writable, so the guide recommends that you copy them to a writable location (owned by you).
nvcc is in the ...cuda/bin, and if you PATH is correct, it should be found. Test it with
nvcc --version The samples all have a Makefile, so the proper way to build a sample is to simply type the command "make" (no quotes) in the sample directory.
Your direct compile would fail because the necessary include files would not be found -- the Makefile has the explicit locations necessary to search for includes in its compile command. There is a top level Makefile in the samples which should run all the individual makefiles for the samples, but some may need additional libraries, and at least one seems to take a lot of memory (simpleSeparateCompilation) and will take forever if it triggers swapping.