I am trying to compile the MATLAB provided example file mexGPUExample.cu following:
The "Set Up for MEX-File Compilation part" was fine. I copied the mex_CUDA_glnxa64.xml file to the current folder and run setenv command.
Then I start to compile mexGPUExample.cu by executing
mex -largeArrayDims mexGPUExample.cu
After it run for a few seconds it got the error message:
Building with 'nvcc'. Error using mex /usr/lib/x86_64-linux-gnu/libc_nonshared.a(atexit.oS): In function `atexit': (.text+0x12): undefined reference to `__cxa_atexit' collect2: error: ld returned 1 exit status
My Machine is Ubuntu 14.04 with gcc 4.8.2 and g++ 4.8.2 The output of gpuDevice is attach in the file.
In order to compatible with mex compile requirement(matlab only support gcc-4.7.x), I set the system default compiler as gcc 4.7 and g++ 4.7 use the method described below:
How to change the default GCC compiler in Ubuntu?
and my output of gpuDevice is: CUDADevice with properties:
Name: 'GeForce GTX 650' Index: 1 ComputeCapability: '3.0' SupportsDouble: 1 DriverVersion: 6.5000 ToolkitVersion: 6 MaxThreadsPerBlock: 1024 MaxShmemPerBlock: 49152 MaxThreadBlockSize: [1024 1024 64] MaxGridSize: [2.1475e+09 65535 65535] SIMDWidth: 32 TotalMemory: 1.0734e+09 AvailableMemory: 490971136 MultiprocessorCount: 2 ClockRateKHz: 1110500 ComputeMode: 'Default' GPUOverlapsTransfers: 1KernelExecutionTimeout: 1 CanMapHostMemory: 1 DeviceSupported: 1 DeviceSelected: 1When I searching for the solutions I only found 2 posts waiting for answer desperately. Lots of thanks to any one who can give a hand. >"<
Best Answer