Problem with CUDA Fortran Example: Matrix Multiply.


I was trying to explore CUDA-Fortran. In our group in the University, we have lots of Fortran code that would be much easier to port to the GPU using CUDA-Fortran instead of C.

I downloaded the Matrix Multiply example from the PG webpage and compile it with the compiler version 64/10.5

It compiles ‘ok’, but when I run it, there’s a segmentation fault when trying to allocate the matrices in the global device memory. I also tried to make the matrices smaller than in the example, but it never works.

I’m using a GeForce 9500 GT which is well recognized by the system (pgaccelinfo returns the good parameters).

Is there anyway of knowing where the error comes from?

Thanks a lot!

Hi Alberto,

I’m assuming you mean this example?

The one caveat to this example is that the data size must be a multiple of 16. The program will crash otherwise. Did you modify the array sizes?

If not, what CUDA driver version do you have? Are you able to run any CUDA program?

Try running the “f1.f90” example code that ships with the compilers. (Adjust the path as necessary)

% pgf90 -V10.5 -fast /usr/pgi/linux86-64/10.5/etc/samples/f1.f90 -ta=nvidia; a.out
       100000 iterations completed
  • Mat

Hi Mat,

Thanks a lot for your response.

Yes, I was careful choosing the array sizes, but it doesn’t work.

I tried to run a very simple program:

program cufinfo2
use cudafor
integer istat, numdevices
istat = cudaGetDeviceCount(numdevices)
write(*,*) 'numdevices', numdevices, 'istat', istat
end program cufinfo2

It compiles well, but the response is clearly wrong:

numdevices 1792231096 istat 35

When I compile it with the emulator flag (running on the CPU), it gives
numdevices=1, istat=0, as it should.

The strange thing is that “pgaccelinfo” recognizes my card and gives
me all the detailed information. It also says that I’m using CUDA driver
version 2020.

Do you know what could be going wrong?

Thanks again,

Hi Alberto,

It also says that I’m using CUDA driver version 2020.

This is the most likely cause. We support CUDA 2.3, 3.0 and 3.1. Your driver is for CUDA 2.2. Can you please try updating your CUDA driver?


Hi Mat,

Thanks a lot! With the new NVIDIA drivers, everything works!!!