Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading module containig printf seems to fail #2

Open
pieterverstraete opened this issue Mar 24, 2014 · 5 comments
Open

Loading module containig printf seems to fail #2

pieterverstraete opened this issue Mar 24, 2014 · 5 comments

Comments

@pieterverstraete
Copy link

I have extended the example that is described in the readme to print out the thread id. The code then looks like this:

#include <stdio.h>

extern "C"   // ensure function name to be exactly "vadd"
{
    __global__ void vadd(const float *a, const float *b, float *c)
    {
        int i = threadIdx.x + blockIdx.x * blockDim.x;
        printf("Thread id %d\n", i);
        c[i] = a[i] + b[i];
    }
} 

I then compile this code to ptx using:

nvcc -ptx -arch=sm_20 vadd.cu

The -arch=sm_20 is added to make the printf work. However, now I cannot load the module into Julia anymore. It keeps complaining about an invalid kernel image:

ERROR: 200
 in error at error.jl:22
 in include_from_node1 at loading.jl:120
while loading /var/cache/workdir/pfverstr/test2.jl, in expression starting on line 16

However, the code does work when I execute the same calls to libcuda (cuInit, cuDeviceGet, cuCtxCreate and cuModuleLoad) from a program written in C++.

@pieterverstraete
Copy link
Author

It seems like it has something to do with dlopen, because when I use dlopen in cpp code, it also fails.

@lindahua
Copy link
Contributor

Would you please let me know the OS you are using?

@pieterverstraete
Copy link
Author

The result of uname -a is:
Linux phoenix 3.13-1-amd64 #1 SMP Debian 3.13.5-1 (2014-03-04) x86_64 GNU/Linux

@maleadt
Copy link
Contributor

maleadt commented Mar 25, 2014

This is because cuCtxCreate is used, while for more recent API versions cuCtxCreate_v2 should be used. Also see my response at http://stackoverflow.com/questions/22612879/cuda-debug-invalid-kernel-image-error/22634798

cuda.h contains API-conditional code managing this. I guess CUDA.jl should mirror (part of) this, selecting proper API calls based on the requested version?

@moon6pence moon6pence mentioned this issue Mar 25, 2014
@lindahua
Copy link
Contributor

I just updated the package, with several bug fixes (e.g. corrected function names and pointer sizes). Please checkout the latest and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants