CUDA and Matlab on Linux : mexcuda not working

13 Ansichten (letzte 30 Tage)
Louis Louis
Louis Louis am 19 Nov. 2015
Kommentiert: Louis Louis am 25 Nov. 2015
Hi,
I'm triing to use the GPU sparse librairie from http://ch.mathworks.com/matlabcentral/fileexchange/44423-gpu-sparse--accumarray--non-uniform-grid but it is impossible for me to correctly compile any file. I tried with both Matlab2015a and Matlab2015b but i've got some dark errors comming from the cusp library like :
Warning: The selected C++ compiler is not supported for CUDA compilation. Searching for a supported compiler.
> In mexcuda (line 89)
Building with 'nvcc'.
Error using mex
In file included from /home/louissarazin/Desktop/lts5usgroup/matlabDev/src/CUsparse/gspmv_coo.cu:44:0:
/usr/local/cuda-7.0/bin/..//include/cusp/blas.h:31:6: warning: #warning | WARNING: cusp/blas.h is deprecated as of 0.4.0; use
cusp/blas/blas.h instead | [-Wcpp]
/usr/local/cuda-7.0/bin/..//include/cusp/system/cuda/detail/multiply/coo_flat_spmv.h(257): error: no operator "=" matches
these operands
operand types are: volatile thrust::complex<float> = thrust::complex<float>
detected during:
instantiation of "void cusp::system::cuda::spmv_coo_flat_kernel<IndexType,ValueType,BLOCK_SIZE>(IndexType,
IndexType, const IndexType *, const IndexType *, const ValueType *, const ValueType *, ValueType *, IndexType *,
ValueType *) [with IndexType=int, ValueType=thrust::complex<float>, BLOCK_SIZE=256U]"
(409): here
instantiation of "void
cusp::system::cuda::__spmv_coo_flat<InitializeY,DerivedPolicy,MatrixType,VectorType1,VectorType2,UnaryFunction,BinaryFunction1,BinaryFunction2>(thrust::system::cuda::detail::execution_policy<DerivedPolicy>
&, MatrixType &, VectorType1 &, VectorType2 &, UnaryFunction, BinaryFunction1, BinaryFunction2) [with
InitializeY=false, DerivedPolicy=thrust::system::cuda::detail::tag, MatrixType=const
cusp::coo_matrix_view<cusp::array1d_view<thrust::device_ptr<const int>>,
cusp::array1d_view<thrust::device_ptr<const int>>, cusp::array1d_view<thrust::device_ptr<const
thrust::complex<float>>>, int, thrust::complex<float>, thrust::device_system_tag>, VectorType1=const
cusp::array1d_view<thrust::device_ptr<const thrust::complex<float>>>,
VectorType2=cusp::array1d_view<thrust::device_ptr<thrust::complex<float>>>,
UnaryFunction=cusp::detail::zero_function<thrust::complex<float>>,
BinaryFunction1=thrust::multiplies<thrust::complex<float>>,
BinaryFunction2=thrust::plus<thrust::complex<float>>]"
(462): here
Ok so first it warns me than my compiler is not supported for CUDA compilation. I'm currently using gcc-4.8.2 (or 4.8.4, is it really matter ?). I also tried to compile the simple exemple and this is what I get :
>> mexcuda -v cusp_test.cu
Warning: The selected C++ compiler is not supported for CUDA compilation. Searching for a supported compiler.
> In mexcuda (line 89)
Trying MEX options '/usr/local/MATLAB/R2015b/toolbox/distcomp/gpu/extern/src/mex/glnxa64/nvcc_g++.xml'...SUCCESS
mex -largeArrayDims -f /usr/local/MATLAB/R2015b/toolbox/distcomp/gpu/extern/src/mex/glnxa64/nvcc_g++.xml NVCC_FLAGS="" -v cusp_test.cu
Verbose mode is on.
... Looking for compiler 'nvcc' ...
... Looking for environment variable 'MW_NVCC_PATH' ...No.
... Looking for environment variable 'CUDA_BIN_PATH' ...No.
... Looking for environment variable 'CUDA_PATH' ...No.
... Executing command 'which nvcc' ...Yes ('/usr/local/cuda-7.0/bin/nvcc').
... Executing command '/usr/local/cuda-7.0/bin/nvcc --version | egrep -E 'release 7.0' > /dev/null && echo /usr/local/cuda-7.0/bin/nvcc' ...Yes ('/usr/local/cuda-7.0/bin/nvcc').
... Executing command '/usr/local/cuda-7.0/bin/nvcc --version | egrep -E 'release 7.0' > /dev/null && echo /usr/local/cuda-7.0/bin/nvcc' ...Yes ('/usr/local/cuda-7.0/bin/nvcc').
... Executing command 'which g++' ...Yes ('/usr/bin/g++').
... Executing command 'g++ -print-file-name=libstdc++.so' ...Yes ('/usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.so').
Found installed compiler 'nvcc'.
Options file details
-------------------------------------------------------------------
Compiler location: /usr/local/cuda-7.0/bin/nvcc
Options file: /usr/local/MATLAB/R2015b/toolbox/distcomp/gpu/extern/src/mex/glnxa64/nvcc_g++.xml
CMDLINE1 : /usr/local/cuda-7.0/bin/nvcc -c --compiler-options=-D_GNU_SOURCE,-DMATLAB_MEX_FILE -I"/usr/local/MATLAB/R2015b/extern/include" -I"/usr/local/MATLAB/R2015b/simulink/include" -I"/usr/local/MATLAB/R2015b/toolbox/distcomp/gpu/extern/include/" -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=\"sm_50,compute_50\" -std=c++11 --compiler-options=-ansi,-fexceptions,-fPIC,-fno-omit-frame-pointer,-pthread -O -DNDEBUG /home/louissarazin/Desktop/lts5usgroup/matlabDev/src/CUsparse/cusp_test.cu -o /tmp/mex_108099938166401_13970/cusp_test.o
CMDLINE2 : /usr/bin/g++ -pthread -Wl,--no-undefined -shared -O -Wl,--version-script,"/usr/local/MATLAB/R2015b/extern/lib/glnxa64/mexFunction.map" /tmp/mex_108099938166401_13970/cusp_test.o -Wl,-rpath-link,/usr/local/MATLAB/R2015b/bin/glnxa64 -L"/usr/local/MATLAB/R2015b/bin/glnxa64" -lmx -lmex -lmat -lm -lmwgpu /usr/local/MATLAB/R2015b/bin/glnxa64/libcudart.so.7.0 -o cusp_test.mexa64
CMDLINE3 : rm -f /tmp/mex_108099938166401_13970/cusp_test.o
CXX : /usr/local/cuda-7.0/bin/nvcc
DEFINES : --compiler-options=-D_GNU_SOURCE,-DMATLAB_MEX_FILE
MATLABMEX : -DMATLAB_MEX_FILE
NVCCFLAGS : -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=\"sm_50,compute_50\" -std=c++11
CXXFLAGS : --compiler-options=-ansi,-fexceptions,-fPIC,-fno-omit-frame-pointer,-pthread
INCLUDE : -I"/usr/local/MATLAB/R2015b/extern/include" -I"/usr/local/MATLAB/R2015b/simulink/include" -I"/usr/local/MATLAB/R2015b/toolbox/distcomp/gpu/extern/include/"
CXXOPTIMFLAGS : -O -DNDEBUG
CXXDEBUGFLAGS : -g
LDXX : /usr/bin/g++
LDFLAGS : -pthread -Wl,--no-undefined
LDTYPE : -shared
LINKEXPORT : -Wl,--version-script,"/usr/local/MATLAB/R2015b/extern/lib/glnxa64/mexFunction.map"
LINKLIBS : -Wl,-rpath-link,/usr/local/MATLAB/R2015b/bin/glnxa64 -L"/usr/local/MATLAB/R2015b/bin/glnxa64" -lmx -lmex -lmat -lm -lmwgpu /usr/local/MATLAB/R2015b/bin/glnxa64/libcudart.so.7.0
LDOPTIMFLAGS : -O
LDDEBUGFLAGS : -g
OBJEXT : .o
LDEXT : .mexa64
NVCC : /usr/local/cuda-7.0/bin/nvcc
GCC : /usr/bin/g++
CPPLIB_DIR : /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.so
MATLABROOT : /usr/local/MATLAB/R2015b
ARCH : glnxa64
SRC : /home/louissarazin/Desktop/lts5usgroup/matlabDev/src/CUsparse/cusp_test.cu
OBJ : /tmp/mex_108099938166401_13970/cusp_test.o
OBJS : /tmp/mex_108099938166401_13970/cusp_test.o
SRCROOT : /home/louissarazin/Desktop/lts5usgroup/matlabDev/src/CUsparse/cusp_test
DEF : /tmp/mex_108099938166401_13970/cusp_test.def
EXP : cusp_test.exp
LIB : cusp_test.lib
EXE : cusp_test.mexa64
ILK : cusp_test.ilk
MANIFEST : cusp_test.mexa64.manifest
TEMPNAME : cusp_test
EXEDIR :
EXENAME : cusp_test
NVCC_FLAGS :
OPTIM : -O -DNDEBUG
LINKOPTIM : -O
-------------------------------------------------------------------
Building with 'nvcc'.
/usr/local/cuda-7.0/bin/nvcc -c --compiler-options=-D_GNU_SOURCE,-DMATLAB_MEX_FILE -I"/usr/local/MATLAB/R2015b/extern/include" -I"/usr/local/MATLAB/R2015b/simulink/include" -I"/usr/local/MATLAB/R2015b/toolbox/distcomp/gpu/extern/include/" -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=\"sm_50,compute_50\" -std=c++11 --compiler-options=-ansi,-fexceptions,-fPIC,-fno-omit-frame-pointer,-pthread -O -DNDEBUG /home/louissarazin/Desktop/lts5usgroup/matlabDev/src/CUsparse/cusp_test.cu -o /tmp/mex_108099938166401_13970/cusp_test.o
/usr/bin/g++ -pthread -Wl,--no-undefined -shared -O -Wl,--version-script,"/usr/local/MATLAB/R2015b/extern/lib/glnxa64/mexFunction.map" /tmp/mex_108099938166401_13970/cusp_test.o -Wl,-rpath-link,/usr/local/MATLAB/R2015b/bin/glnxa64 -L"/usr/local/MATLAB/R2015b/bin/glnxa64" -lmx -lmex -lmat -lm -lmwgpu /usr/local/MATLAB/R2015b/bin/glnxa64/libcudart.so.7.0 -o cusp_test.mexa64
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
I tried to change the nvcc_g++ but really successfully. Any clue ?
Thanks,
louis.

Antworten (1)

Joss Knight
Joss Knight am 24 Nov. 2015
I believe this is due to missing C++ libraries that aren't linked by default by mexcuda because they can cause issues with nvcc in CUDA 7.0 and before. Try adding -lstdc++ to your compilation and report back.
  1 Kommentar
Louis Louis
Louis Louis am 25 Nov. 2015
Effectively one library was not linked correctly :
>> mexcuda -lc mexGPUExample.cu
does the trick. Thank you !
So now I go back to my first problem which seems to be more relative to CUDA, Thrust and CUSp than to MATLAB :
/usr/local/cuda-7.0/bin/..//include/cusp/system/cuda/detail/multiply/coo_flat_spmv.h(257): error: no operator "=" matches
these operands
operand types are: volatile thrust::complex<float> = thrust::complex<float>
It should be an incompatibility error between Thrust and Cusp version. Maybe I should also linked these libraries for the compilation ? I will investigate it.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Call C++ from MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by