As long as you are compiling caffe in a directory you have write-access to, you
do not need to use sudo. You should have read privileges to /usr/local/cuda, and that is enough. The only thing you have to do is telling the linker where to find the cuda libs at runtime, because they are not in the standard lib paths. So a simple
$ LD_LIBRARY_PATH=/usr/local/cuda/lib64 make runtest
should do the trick (
if you have an installed and activated nvidia driver and GPU in your system, of course). If you need to use sudo for compilation or running of caffe, you are doing something wrong. The only part where you might need sudo is for the installation of caffe's dependencies, if you install them to the standard paths and/or through your distro's packaging system.
Jan
P.S. Understanding why these errors happen and how to solve them brings you a lot farther in understanding development in and the inner workings of the linux operating system, which in turn will prevent you from making such errors in the future or at least solving them with ease. Nobody is a pro from the start, but you should always strive to improve your knowledge and skills. Just saying. (because we get a lot of questions like this on this forum, which are actually only basic linux development questions, not really caffe-specific.)