RuntimeError: cuda error invalid device function(98) occurred;

为使您的问题得到快速解决,建议参考以下模板:

【标题】
安装完Megengine后,运行小模型盲去噪问题示例代码统计参数量时报错
【版本、环境信息】

  • MegEngine 版本:1.8.2
  • CPU型号:Intel® Core™ i7-7500U CPU @ 2.70GHz 2.90 GHz
  • GPU型号:Nvidia GeForce 940MX
  • 系统环境:Win 10 64位
  • python版本: 3.8.11

【如为报错请提供以下复现信息】

  • 复现步骤:运行小模型盲去噪示例代码,模型只是一个小型卷积神经网络
  • 日志信息:RuntimeError: cuda error invalid device function(98) occurred; expr: cudaOccupancyMaxPotentialBlockSizeVariableSMem( &ret.grid_size,
    &ret.block_size, kern, s) error file:…/…/…/dnn/src/cuda/query_blocksize_impl.cu:50

backtrace:
2 null

3 null

4 null

5 null

6 null

7 null

8 null

9 null

10 null

11 null

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “c:\Users\tangjiayi\Desktop\denoise\test.py”, line 41, in
net = Predictor()
File “c:\Users\tangjiayi\Desktop\denoise\test.py”, line 13, in init
M.Conv2d(4, 50, 3, padding = 1, bias = True),
File “E:\Anaconda3\envs\Meg\lib\site-packages\megengine\module\conv.py”, line 378, in init
super().init(
File “E:\Anaconda3\envs\Meg\lib\site-packages\megengine\module\conv.py”, line 62, in init
self.reset_parameters()
File “E:\Anaconda3\envs\Meg\lib\site-packages\megengine\module\conv.py”, line 73, in reset_parameters
init.zeros_(self.bias)
File “E:\Anaconda3\envs\Meg\lib\site-packages\megengine\module\init.py”, line 36, in zeros_
fill_(tensor, 0)
File “E:\Anaconda3\envs\Meg\lib\site-packages\megengine\module\init.py”, line 27, in fill_
tensor._reset(full(shape=tensor.shape, value=val, dtype=tensor.dtype))
File “E:\Anaconda3\envs\Meg\lib\site-packages\megengine\functional\tensor.py”, line 175, in full
return broadcast_to(x, shape)
File “E:\Anaconda3\envs\Meg\lib\site-packages\megengine\functional\tensor.py”, line 355, in broadcast_to
return _broadcast(inp, shape)
File “E:\Anaconda3\envs\Meg\lib\site-packages\megengine\core\tensor\array_method.py”, line 135, in _broadcast
(result,) = apply(builtin.Broadcast(), inp, shape)
megengine.core._imperative_rt.core2.AsyncError: An async error is reported. See above for the actual cause. Hint: This is where it is reported, not where it happened. You may call `megengine.config.async_level = 0 to get better error reporting.

  • 代码关键片段:total_stats, stats_details = module_stats(
    net,
    inputs = (input_data,),
    cal_params = True,
    cal_flops = True,
    logging_to_stdout = True,
    )

Nvidia GeForce 940MX SM 默认没有编译