文章目录
- 环境
- matconvnet
- 设置mex
- cl.exe
- CPU版本,直接
- GPU版本:
- 问题一:
- 问题二:
- 问题三
- 编译GPU支持
- 测试:
Ref: https://www.vlfeat.org/matconvnet/install/
环境
- win11
- Matlab R2022a
- Vs2019
- CUDA11.3
- CUDNN 8.7.9
- Matlab工具箱:
Parallel Computing Toolbox
Signal Processing Toolbox
matconvnet
https://github.com/vlfeat/matconvnet
下载v1.0-beat24
设置mex
mex -setup C++
cl.exe
‘cl.exe’ 不是内部或外部命令,也不是可运行的程序 或批处理文件
搜索cl_path, 设置自己的cl.exe路径
cl_path = fullfile('D:\program\VS2017\', 'VC', 'Tools', 'MSVC','14.16.27023','bin','Hostx64','x64');
CPU版本,直接
vl_compilenn
GPU版本:
错误使用 vl_nnconv
The option name is not a string (argument number 5)
问题一:
vl_compilenn>search_cuda_devkit
Could not find a valid NVCC executable\n
搜索for v
添加自己的CUDA版本
for v = {'5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0','11.3'}
问题二:
‘-DNDEBUG’: expected a number
搜索nvcc_compile函数,利用下面代码进行替换
function nvcc_compile(opts, src, tgt, flags)
% --------------------------------------------------------------------
mybase=flags.base;
mybase(3)={'-O3'};
if check_deps(opts, tgt, src), return ; end
nvcc_path = fullfile(opts.cudaRoot, 'bin', 'nvcc');
nvcc_cmd = sprintf('"%s" -c -o "%s" "%s" %s ', ...nvcc_path, tgt, src, ...strjoin(horzcat(mybase,flags.nvcc)));
opts.verbose && fprintf('%s: NVCC CC: %s\n', mfilename, nvcc_cmd) ;
status = system(nvcc_cmd);
if status, error('Command %s failed.', nvcc_cmd); end;
问题三
使用了 ‘-R2018a’ 进行编译并与 ‘-R2017b’ 链接在一起。 有关详细信息,请参阅 MEX 文件使用了一个 API 进行编译并与另一个 API 链接在一起。
将vl_compilenn.m中的largeArrayDims全部替换为lmwblas,一共三处
编译GPU支持
vl_compilenn(‘enableGpu’, true, ‘Debug’,true’, ‘cudaMethod’, ‘nvcc’,‘cudaRoot’, ‘C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3’,‘enableCudnn’, true, ‘cudnnRoot’, ‘C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3’)
测试:
vl_testnn(‘gpu’, true)