Display all NVCC warnings in PyCUDA - cuda

[update] How can I output the warning messages from compiler.SourceModule(kernel_code)?
With help of #flipchart I was able to pass the right parameters to NVCC trough PyCUDA, but I still don't know, where to access the compiler warnings.
[original question]
Using NVCC directly one can use the compiler switch -Wall*. How would one archive this in pycuda?
I tried mod = compiler.SourceModule(kernel_code,options=['-Wall']), but the error message states:
pytools.prefork.ExecError: error invoking 'nvcc --cubin -Wall -arch sm_11 -I/usr/local/lib/python2.6/dist-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/../include/pycuda kernel.cu': status 255 invoking 'nvcc --cubin -Wall -arch sm_11 -I/usr/local/lib/python2.6/dist-packages/pycuda-0.94.2-py2.6-linux-x86_64.egg/pycuda/../include/pycuda kernel.cu': nvcc fatal : Unknown option 'Wall'
The source problem is, that I spent a whole day debugging, because I overlooked an inexplicit conversion fromfloat to int.
*Warnings from system-header with "--compiler-options -Wall" since CUDA 3.0

The -Wall option is not a nvcc compiler option, but rather one that is passed on to the supporting compiler (g++ or cl.exe). You need to pass in the option --compiler-options -Wall to indicate to nvcc that the option is for the supporting compiler. In you python code:
mod = compiler.SourceModule(kernel_code,options=['--compiler-options','-Wall'])
PyCuda seems to want each option specified as a list item, otherwise it wraps the whole thing in quotes which nvcc doesn't like.

Related

not able to disable exception boost managed_mapped_file

I am having problems compiling my application with boost::managed_mapped_file without exceptions. am compiling it with the flags -DBOOST_NO_EXCEPTIONS -DBOOST_NO_EXCEPTIONS but still get
g++ -c -Wall -g -O0 -Wno-write-strings -fno-exceptions -DBOOST_NO_EXCEPTIONS -DBOOST_NO_EXCEPTIONS -I./ -I../Include/ UT_main.cpp -o UT_main.o"
In file included from /usr/include/boost/interprocess/mapped_region.hpp:18
from /usr/include/boost/interprocess/detail/managed_open_or_create_impl.hpp:17
from /usr/include/boost/interprocess/managed_mapped_file.hpp:20
from ../Include/MyMng.h:11
from main.cpp:7:
/usr/include/boost/interprocess/exceptions.hpp: In constructor interprocess_exception
/usr/include/boost/interprocess/exceptions.hpp:40: error: exception handling disabled, use -fexceptions to enable
from what i see in the code whenever the the -DBOOST_NO_EXCEPTIONS is on the interprocess/exceptions.hpp is still included but only the "include " is not included. It seems that the code should work withould exceptions.
if someone can tell me what am i missing
thanks
Compiling that library isn't supported without exceptions.
Many functions are explicitly documented (e.g. on existing files when using create_only).
The throws are unconditional (IOW it doesn't use Boost Exception's macros to replace exceptions by a user-defined callback).
For completeness: the header you see in the message fails to compile because it uses try/catch internally (to avoid exceptions during exception handling).

Trouble compiling/running CUDA code involving dynamic parallelism

I am trying to use dynamic parallelism with CUDA, but I cannot go through the compilation step.
I am working on a GPU with Compute Capability 3.5 and the CUDA version 7.5.
Depending on the switches in the compile command I use, I am getting different error messages, but using the documentation,
I arrived to one line leading to a successful compilation:
nvcc -arch=compute_35 -rdc=true cudaDynamic.cu -o cudaDynamic.out -lcudadevrt
But when the program is launched, all the program fails. With
CUDA-memcheck, for each call to an API function, I get the same error
message:
========= CUDA-MEMCHECK
========= Program hit cudaErrorUnknown (error 30) due to "unknown error" on CUDA API call to ...
I have also tried this line (taken from CUDA dynamic samples makefile):
nvcc -ccbin g++ -I../../common/inc -m64 -dc -gencode arch=compute_35,code=compute_35 -o cudaDynamic.out -c cudaDynamic.cu
But upon execution, I get:
cudaDynamic.out: Permission denied
I would like to understand how to correctly compile a CUDA dynamic code, because all the other compilation lines that I have tried so far have failed.
I fixed the problem by fully reinstalling CUDA.
I'm now able to compile both the CUDA samples and my own code.

fatal error while compiling cuda program

I'm implementing a program by using dynamic parallelism. Whenever I'm compiling the code, it is throwing fatal error as follows:
ptxas fatal : Unresolved extern function 'cudaGetParameterBuffer'
Compiling as below:
nvcc -o dyn_par dyn_par.cu -arch=sm_35
How to resolve it?
The cudaGetParameterBuffer is part of the cudadevrt library which you need to specify in your compiler command and specify --relocatable-device-code as true
nvcc -o dyn_par dyn_par.cu -arch=sm_35 -lcudadevrt --relocatable-device-code true
Have a look at the CUDA Dynamic Parallelism Programming Guide from Nvidia (Page 21 describes the above) for more information

Compile Error Changing Backend System of Thrust with CUDA 5

I installed CUDA 5 recently and found existing code based on Thrust cannot be compiled. The error only happens if I switch to OMP or TBB.
So I did an experiment using monte_carlo.cpp from Thrust example.
When I using include path of CUDA 5.0, I got this error:
g++ -O2 -o monte_carlo monte_carlo.cpp
-DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP -fopenmp -I /usr/local/cuda-5.0/include/
/tmp/ccFsJtAs.o: In function main': monte_carlo.cpp:(.text+0xa0):
undefined reference tofloat
thrust::detail::backend::cuda::reduce_n, float,
thrust::use_default>, long, float, thrust::plus
(thrust::transform_iterator, float,
thrust::use_default>, long, float, thrust::plus)'
But if I change to CUDA 4.1 using
g++ -O2 -o monte_carlo monte_carlo.cpp
-DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP -fopenmp -I /usr/local/cuda-4.1/include/
There is no error.
And my platform is Ubuntu 10.04 with g++ 4.4.3.
Hope anyone can help me, thanks!
Edit
OMP problem is solved by changing the order of -fopenmp as #Robert pointed out, but I failed to compile using TBB
g++ -O2 -o monte_carlo monte_carlo.cpp -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_TBB -ltbb -I /usr/local/cuda/include/
/tmp/ccxSmcnJ.o: In function main':
monte_carlo.cpp:(.text+0xa0): undefined reference tofloat thrust::detail::backend::cuda::reduce_n, float, thrust::use_default>, long, float, thrust::plus >(thrust::transform_iterator, float, thrust::use_default>, long, float, thrust::plus)'
collect2: ld returned 1 exit status
But the compilation successes if I use
g++ -O2 -o monte_carlo monte_carlo.cpp -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_TBB -ltbb -I /usr/local/cuda-4.1/include/
The OpenMP compilation would appear to have been caused by incorrectly specified compilation arguments. Compiling using
g++ -O2 -o monte_carlo monte_carlo.cpp -fopenmp -DTHRUST_DEVICE_BACKEND=THRUST_DEVICE_BACKEND_OMP -lgomp -I\usr\local\cuda\include
(i.e. specifying OpenMP code generation before any pre-processor directives) allowed for correct compilation using the thrust OpenMP backed.
The reported TBB back end compilation error would appear to have been caused by attempting to use the TBB backend on thrust 1.5.3, which has no TBB support.
[This answer has been assembled from question edits and comments to get the question off the unanswered list for the CUDA tag]

Why won't Sage compile my code?

Sage is supposed to be able to create compiled code using Cython. I have never been able to get this to work. The problem appears to be with my Sage installation, since compiling fails on the included example. I don't believe I did anything special during installation, but apparently I something wrong. The Sage tutorial says
In order to make your own compiled Sage code, give the file an .spyx extension (instead of .sage). If you are working with the command-line interface, you can attach and load compiled code exactly like with interpreted code (at the moment, attaching and loading Cython code is not supported with the notebook interface). The actual compilation is done “behind the scenes” without your having to do anything explicit. See $SAGE_ROOT/examples/programming/sagex/factorial.spyx for an example of a compiled implementation of the factorial function that directly uses the GMP C library. To try this out for yourself, cd to $SAGE_ROOT/examples/programming/sagex/, then do the following:
sage: load "factorial.spyx"
When I try I get the following message:
Compiling ./factorial.spyx...
Error compiling cython file:
Error compiling ./factorial.spyx:
running build
running build_ext
building '_home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0' extension
creating build
creating build/temp.linux-i686-2.6
gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/include/csage/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/include/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/include/python2.6/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/lib/python2.6/site-packages/numpy/core/include -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/sage/sage/ext/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/sage/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/sage/sage/gsl/ -I. -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/include/python2.6 -c _home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0.c -o build/temp.linux-i686-2.6/_home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0.o -w -O2
creating build/lib.linux-i686-2.6
gcc -pthread -shared build/temp.linux-i686-2.6/_home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0.o -L/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local//lib/ -L/home/wstein/build/sage-4.7.1/local/lib -lmpfr -lgmp -lgmpxx -lstdc++ -lpari -lm -lcurvesntl -lg0nntl -ljcntl -lrankntl -lgsl -lgslcblas -latlas -lntl -lcsage -lpython2.6 -o build/lib.linux-i686-2.6/_home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0.so -L/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local//lib
/usr/bin/ld: cannot find -lstdc++ collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Any suggestions? Thanks.
Per DSM's comment, I reinstalled g++-multilib, and now everything works fine.