architecture problem when compiling the example

I am a green horse of programing using CUDA, so I am trying to learn it from the examples.

I’m using Mac OS X 10.6.4 and Matlab 7.8.0 (R2009a).

I downloaded the example and tried to compile it (using command in Terminal, not in Matlab). But I met the following error:

/Applications/MATLAB.app/bin/mex CFLAGS=’-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=’-O3 -funroll-loops -msse2’ fft2_cuda.c
-I/usr/local/cuda/include -L/usr/local/cuda/lib -lcuda -lcudart -lcufft -Wl,-rpath,/usr/local/cuda/lib
/Applications/MATLAB.app/bin/mex CFLAGS=’-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=’-O3 -funroll-loops -msse2’ fft2_cuda_sp_dp.c
-I/usr/local/cuda/include -L/usr/local/cuda/lib -lcuda -lcudart -lcufft -Wl,-rpath,/usr/local/cuda/lib
/Applications/MATLAB.app/bin/mex CFLAGS=’-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=’-O3 -funroll-loops -msse2’ ifft2_cuda.c
-I/usr/local/cuda/include -L/usr/local/cuda/lib -lcuda -lcudart -lcufft -Wl,-rpath,/usr/local/cuda/lib
./nvmex -f nvopts.sh Szeta.cu -I/usr/local/cuda/include -L/usr/local/cuda/lib -lcuda -lcudart -lcufft -Wl,-rpath,/usr/local/cuda/lib
ld: warning: in Szeta.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in mexversion.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Applications/MATLAB.app/bin/maci/libmx.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Applications/MATLAB.app/bin/maci/libmex.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Applications/MATLAB.app/bin/maci/libmat.dylib, file was built for i386 which is not the architecture being linked (x86_64)

When running the following script in Matlab

tic; FS_2Dturb(128,1,1,1); toc;

I got
??? Invalid MEX-file
‘/Work/utils/filters/Cuda_FFT2/Szeta.mexmaci’:
dlopen(/Work/utils/filters/Cuda_FFT2/Szeta.mexmaci,
1): no suitable image found. Did find:
/Work/utils/filters/Cuda_FFT2/Szeta.mexmaci:
mach-o, but wrong architecture.

Error in ==> FS_2Dturb at 89
d1 = dt*Szeta(zeta,k,nu4);

Anyone can help me? Thanks a lot!

I am a green horse of programing using CUDA, so I am trying to learn it from the examples.

I’m using Mac OS X 10.6.4 and Matlab 7.8.0 (R2009a).

I downloaded the example and tried to compile it (using command in Terminal, not in Matlab). But I met the following error:

/Applications/MATLAB.app/bin/mex CFLAGS=’-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=’-O3 -funroll-loops -msse2’ fft2_cuda.c
-I/usr/local/cuda/include -L/usr/local/cuda/lib -lcuda -lcudart -lcufft -Wl,-rpath,/usr/local/cuda/lib
/Applications/MATLAB.app/bin/mex CFLAGS=’-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=’-O3 -funroll-loops -msse2’ fft2_cuda_sp_dp.c
-I/usr/local/cuda/include -L/usr/local/cuda/lib -lcuda -lcudart -lcufft -Wl,-rpath,/usr/local/cuda/lib
/Applications/MATLAB.app/bin/mex CFLAGS=’-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=’-O3 -funroll-loops -msse2’ ifft2_cuda.c
-I/usr/local/cuda/include -L/usr/local/cuda/lib -lcuda -lcudart -lcufft -Wl,-rpath,/usr/local/cuda/lib
./nvmex -f nvopts.sh Szeta.cu -I/usr/local/cuda/include -L/usr/local/cuda/lib -lcuda -lcudart -lcufft -Wl,-rpath,/usr/local/cuda/lib
ld: warning: in Szeta.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in mexversion.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Applications/MATLAB.app/bin/maci/libmx.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Applications/MATLAB.app/bin/maci/libmex.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Applications/MATLAB.app/bin/maci/libmat.dylib, file was built for i386 which is not the architecture being linked (x86_64)

When running the following script in Matlab

tic; FS_2Dturb(128,1,1,1); toc;

I got
??? Invalid MEX-file
‘/Work/utils/filters/Cuda_FFT2/Szeta.mexmaci’:
dlopen(/Work/utils/filters/Cuda_FFT2/Szeta.mexmaci,
1): no suitable image found. Did find:
/Work/utils/filters/Cuda_FFT2/Szeta.mexmaci:
mach-o, but wrong architecture.

Error in ==> FS_2Dturb at 89
d1 = dt*Szeta(zeta,k,nu4);

Anyone can help me? Thanks a lot!

Hi Ben, Welcome to the world of GPU computing! My guess is that there are some 32-bit vs 64-bit mismatches in the stuff you’re trying to plug together. We have a ton of documentation at http://wiki.accelereyes.com around GPU computing with MATLAB and have setup instructions for the Mac there that will help get your dylib files correct. Good luck!

-John

Hi Ben, Welcome to the world of GPU computing! My guess is that there are some 32-bit vs 64-bit mismatches in the stuff you’re trying to plug together. We have a ton of documentation at http://wiki.accelereyes.com around GPU computing with MATLAB and have setup instructions for the Mac there that will help get your dylib files correct. Good luck!

-John