mexcuda in ubuntu error

조회 수: 7 (최근 30일)
Y.Yang
Y.Yang 2021년 2월 28일
답변: Joss Knight 2021년 3월 8일
Try to complie the Cuda file in ubuntu system but get error.
mexcuda GEMM_GPU.cu -lcublas
Building with 'nvcc'.
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu: In function void mexFunction(int, mxArray**, int, const mxArray**):
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu:164:55: warning: narrowing conversion of ‘numCRows’ from ‘long long int’ to ‘mwSize {aka long unsigned int}’ inside { } [-Wnarrowing]
const mwSize dims[] = {numCRows,numCCols,batch_count};
^
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu:164:55: warning: narrowing conversion of ‘numCCols’ from ‘long long int’ to ‘mwSize {aka long unsigned int}’ inside { } [-Wnarrowing]
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu:164:55: warning: narrowing conversion of ‘batch_count’ from ‘int’ to ‘mwSize {aka long unsigned int}’ inside { } [-Wnarrowing]
Error using mex
/usr/bin/x86_64-linux-gnu-ld: cannot find -lcublas
collect2: error: ld returned 1 exit status
Error in mexcuda (line 166)
[varargout{1:nargout}] = mex(mexArguments{:});
As the cuda file uses cublas_v2 liburary, I add the path of the CUDA h files in the commend line but the error still exists:
mexcuda GEMM_GPU.cu -lcublas -I'/usr/local/cuda-9.0/include'
Building with 'nvcc'.
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu(164): warning: invalid narrowing conversion from "long long" to "unsigned long"
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu: In function void mexFunction(int, mxArray**, int, const mxArray**):
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu:164:55: warning: narrowing conversion of ‘numCRows’ from ‘long long int’ to ‘mwSize {aka long unsigned int}’ inside { } [-Wnarrowing]
const mwSize dims[] = {numCRows,numCCols,batch_count};
^
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu:164:55: warning: narrowing conversion of ‘numCCols’ from ‘long long int’ to ‘mwSize {aka long unsigned int}’ inside { } [-Wnarrowing]
/home/ubuntu/New_folder/Local_version/GEMM_GPU.cu:164:55: warning: narrowing conversion of ‘batch_count’ from ‘int’ to ‘mwSize {aka long unsigned int}’ inside { } [-Wnarrowing]
Error using mex
/usr/bin/x86_64-linux-gnu-ld: cannot find -lcublas
collect2: error: ld returned 1 exit status
Error in mexcuda (line 166)
[varargout{1:nargout}] = mex(mexArguments{:});
Here are my device information after calling gpuDevice:
gpuDevice(1)
ans =
CUDADevice with properties:
Name: 'GeForce GTX 1080 Ti'
Index: 1
ComputeCapability: '6.1'
SupportsDouble: 1
DriverVersion: 10.2000
ToolkitVersion: 10.2000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 1.1718e+10
AvailableMemory: 1.1399e+10
MultiprocessorCount: 28
ClockRateKHz: 1582000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 0
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
Here are the information after running gpu environment checker
puEnvObj = coder.gpuEnvConfig;
gpuEnvObj.GpuId = 1;
gpuEnvObj.BasicCodegen = 1;
gpuEnvObj.BasicCodeexec = 1;
results = coder.checkGpuInstall(gpuEnvObj)
Compatible GPU : PASSED
CUDA Environment : PASSED
Runtime : PASSED
cuFFT : PASSED
cuSOLVER : PASSED
cuBLAS : PASSED
Basic Code Generation : PASSED
Basic Code Execution : PASSED
results =
struct with fields:
gpu: 1
cuda: 1
cudnn: 0
tensorrt: 0
basiccodegen: 1
basiccodeexec: 1
deepcodegen: 0
deepcodeexec: 0
tensorrtdatatype: 0
profiling: 0
I try to find whether it is because of the problem of GCC, but it looks fine once I just try to use mexcuda to complie some CUDA files which don't need cublas lib:
mexcuda cuda_file_without_cublas_lib.cu
The cu file will be successfully completed without any warnning or errors.
  댓글 수: 1
Joss Knight
Joss Knight 2021년 3월 8일
The path to cublas is automatically inserted into the build line. Since adding a path to an incompatible version of the CUDA toolkit was one of the things you tried, perhaps MATLAB is using an incompatible version of the toolkit? Please run your call to mexcuda with the -v option so we can see the complete command line output.

댓글을 달려면 로그인하십시오.

채택된 답변

Joss Knight
Joss Knight 2021년 3월 8일
Try
mexcuda -lcublas GEMM_GPU.cu

추가 답변 (2개)

Shadaab Siddiqie
Shadaab Siddiqie 2021년 3월 3일
Such errors might be caused due to the following reasons:
1) The 'mexcuda' is using incorrect version of 'nvcc'. Set the 'MW_NVCC_PATH' to the bin directory of the correct cuda installation.
>>setenv('MW_NVCC_PATH','/usr/local/CUDA/bin')
2) The 'g++' version is not compatible with the 'nvcc' version.
Check the the NVIDIA Developers website to find the compatible versions of g++ and update gcc/g++ to the recommended version. This is important because updating the gcc version will update the standard c/c++ libraries.

Joss Knight
Joss Knight 2021년 3월 8일
편집: Joss Knight 2021년 3월 8일
Your declaration
const mwSize dims[] = {numCRows,numCCols,batch_count};
Is casting away the signed-ness of your variable numCRows and numCCols, because they are signed int64s and mwSize is a size_t (unsigned long int). All you have to do is force it (e.g. use a static_cast) or disable this compiler warning. Or just declare numCRows and numCCols as type mwSize in the first place.
Edit: Oh, and the same goes for batch_count.

카테고리

Help CenterFile Exchange에서 Beamforming and Direction of Arrival Estimation에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by