mexcuda in ubuntu error

1 次查看(过去 30 天)
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 中查找有关 GPU Computing 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by