问题:
环境:
- Windows 10
- Matlab2018b
- gpuDevice: GeForce RTX 2080 Ti
- nvcc --version: Cuda compilation tools, release 10.2, V10.2.89
matlab 运行Deep Learning Toolbox Model for AlexNet Network 代码 报错
net = alexnet
layer = 'conv1'
channels = 1:36
I = deepDreamImage(net,layer,channels,...
'PyramidLevels',1,...
'Verbose',0)
figure
for i = 1:36
subplot(6,6,i)
imshow(I(:,:,:,i))
end
代码来自博客:如何可视化卷积神经网络特征(基于matlab R2018b)
警告: The CUDA driver must recompile the GPU libraries because your device is more recent than the libraries. Recompiling can take several minutes. Learn more.
错误使用 nnet.internal.cnngpu.convolveForward2D
Unexpected error calling cuDNN: CUDNN_STATUS_EXECUTION_FAILED.
解决
方法1:
在matlab命令行输入:
>> gpuDevice
ans =
CUDADevice - 属性:
Name: 'GeForce RTX 2080 Ti'
Index: 1
ComputeCapability: '7.5'
SupportsDouble: 1
DriverVersion: 10.2000
>> nvcc --version
未定义函数或变量 'nvcc'。
在matlab中配置CUDA环境变量
操作:
点击:主页 ,设置路径,添加文件夹,选择下面两个路径:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\libnvvp
添加完成后点击保存。
之后再次运行代码,可以成功运行啦。
方法2:(玄学但是有用…)
在代码中随意添加一行:将0.0001存入GUP中,之后再重新运行net = trainNetwork( ),不会出现报错问题。
ile = gpuArray(0.0001);
net = trainNetwork(XTrain,YTrain,lgraph_1,options);