<p dir="auto">Per <a href="https://arxiv.org/abs/1502.01852" rel="nofollow">https://arxiv.org/abs/1502.01852</a> I'm giving the channel-wise <a href="http://pytorch.org/docs/stable/nn.html#torch.nn.PReLU" rel="nofollow">PReLUs</a> a try, as in:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="nn.PReLU(num_parameters=num_channels)"><pre class="notranslate"><code class="notranslate">nn.PReLU(num_parameters=num_channels)
</code></pre></div>
<p dir="auto">When accidentally getting the <code class="notranslate">num_parameters</code> argument wrong it seems like we crash hard with an invalid <code class="notranslate">free</code> somewhere in native code.</p>
<p dir="auto">Can we put some guards in place to not hard-crash here and maybe even show the user a useful error message?</p>
<p dir="auto">Here is the crash log, hope that helps:</p>
<details>
<summary>Backtrace</summary>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="*** Error in `python3': free(): invalid pointer: 0x00007fb5ee875d40 ***                                                                                                                                   [179/1882]
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fb5ff54f7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fb5ff55837a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fb5ff55c53c]
/usr/local/lib/python3.6/dist-packages/torch/_thnn/_THCUNN.cpython-36m-x86_64-linux-gnu.so(+0x2b492)[0x7fb5a6d96492]
python3(_PyCFunction_FastCallKeywords+0x9e)[0x51e55e]
python3[0x5789e9]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3(PyEval_EvalCodeEx+0x28c)[0x578f4c]
python3[0x4f6b73]
python3(PyObject_Call+0x3a)[0x4e2f0a]
/usr/local/lib/python3.6/dist-packages/torch/_C.cpython-36m-x86_64-linux-gnu.so(_Z17THPFunction_applyP7_objectS0_+0x271)[0x7fb5ed37dac1]
python3(_PyCFunction_FastCallKeywords+0x9e)[0x51e55e]
python3[0x5789e9]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3[0x5799fd]
python3[0x578acc]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3(_PyFunction_FastCallDict+0x133)[0x57a3e3]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3(_PyEval_EvalFrameDefault+0x1ab5)[0x5729e5]
python3[0x57047f]
python3(_PyFunction_FastCallDict+0x1da)[0x57a48a]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3[0x5333ee]
python3(_PyObject_FastCallKeywords+0x10b)[0x4e2a2b]
python3[0x578b75]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3(_PyFunction_FastCallDict+0x133)[0x57a3e3]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3(_PyEval_EvalFrameDefault+0x1ab5)[0x5729e5]
python3[0x57047f]
python3(_PyFunction_FastCallDict+0x1da)[0x57a48a]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3[0x5333ee]
python3(_PyObject_FastCallKeywords+0x10b)[0x4e2a2b]
python3[0x578b75]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3(_PyFunction_FastCallDict+0x133)[0x57a3e3]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3(_PyEval_EvalFrameDefault+0x1ab5)[0x5729e5]
python3[0x57047f]
python3(_PyFunction_FastCallDict+0x1da)[0x57a48a]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3[0x5333ee]
python3(_PyObject_FastCallKeywords+0x10b)[0x4e2a2b]
python3[0x578b75]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3[0x5799fd]
python3[0x578acc]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3[0x5707ae]
python3[0x579abb]
python3[0x578acc]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3[0x57047f]
python3(PyEval_EvalCode+0x23)[0x5701f3]
python3[0x56e0ee]"><pre class="notranslate"><code class="notranslate">*** Error in `python3': free(): invalid pointer: 0x00007fb5ee875d40 ***                                                                                                                                   [179/1882]
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fb5ff54f7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fb5ff55837a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fb5ff55c53c]
/usr/local/lib/python3.6/dist-packages/torch/_thnn/_THCUNN.cpython-36m-x86_64-linux-gnu.so(+0x2b492)[0x7fb5a6d96492]
python3(_PyCFunction_FastCallKeywords+0x9e)[0x51e55e]
python3[0x5789e9]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3(PyEval_EvalCodeEx+0x28c)[0x578f4c]
python3[0x4f6b73]
python3(PyObject_Call+0x3a)[0x4e2f0a]
/usr/local/lib/python3.6/dist-packages/torch/_C.cpython-36m-x86_64-linux-gnu.so(_Z17THPFunction_applyP7_objectS0_+0x271)[0x7fb5ed37dac1]
python3(_PyCFunction_FastCallKeywords+0x9e)[0x51e55e]
python3[0x5789e9]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3[0x5799fd]
python3[0x578acc]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3(_PyFunction_FastCallDict+0x133)[0x57a3e3]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3(_PyEval_EvalFrameDefault+0x1ab5)[0x5729e5]
python3[0x57047f]
python3(_PyFunction_FastCallDict+0x1da)[0x57a48a]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3[0x5333ee]
python3(_PyObject_FastCallKeywords+0x10b)[0x4e2a2b]
python3[0x578b75]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3(_PyFunction_FastCallDict+0x133)[0x57a3e3]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3(_PyEval_EvalFrameDefault+0x1ab5)[0x5729e5]
python3[0x57047f]
python3(_PyFunction_FastCallDict+0x1da)[0x57a48a]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3[0x5333ee]
python3(_PyObject_FastCallKeywords+0x10b)[0x4e2a2b]
python3[0x578b75]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3(_PyFunction_FastCallDict+0x133)[0x57a3e3]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3(_PyEval_EvalFrameDefault+0x1ab5)[0x5729e5]
python3[0x57047f]
python3(_PyFunction_FastCallDict+0x1da)[0x57a48a]
python3(_PyObject_Call_Prepend+0x24c)[0x4e383c]
python3(PyObject_Call+0x3a)[0x4e2f0a]
python3[0x5333ee]
python3(_PyObject_FastCallKeywords+0x10b)[0x4e2a2b]
python3[0x578b75]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3[0x5799fd]
python3[0x578acc]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3[0x5707ae]
python3[0x579abb]
python3[0x578acc]
python3(_PyEval_EvalFrameDefault+0x3da)[0x57130a]
python3[0x57047f]
python3(PyEval_EvalCode+0x23)[0x5701f3]
python3[0x56e0ee]
</code></pre></div>
</details>
<h2 dir="auto">System Info</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PyTorch version: 0.3.1
Is debug build: No
CUDA used to build PyTorch: 8.0.61

OS: Ubuntu 16.04.4 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
CMake version: version 3.5.1

Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 8.0.61
GPU models and configuration: GPU 0: Tesla K80
Nvidia driver version: 384.66
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.6.0.21
/usr/lib/x86_64-linux-gnu/libcudnn_static_v6.a
/usr/local/lib/python3.6/dist-packages/torch/lib/libcudnn-900fef33.so.7.0.5

Versions of relevant libraries:
[pip3] numpy (1.14.2)
[pip3] torch (0.3.1)
[pip3] torchvision (0.2.0)
[conda] Could not collect"><pre class="notranslate"><code class="notranslate">PyTorch version: 0.3.1
Is debug build: No
CUDA used to build PyTorch: 8.0.61

OS: Ubuntu 16.04.4 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
CMake version: version 3.5.1

Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 8.0.61
GPU models and configuration: GPU 0: Tesla K80
Nvidia driver version: 384.66
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.6.0.21
/usr/lib/x86_64-linux-gnu/libcudnn_static_v6.a
/usr/local/lib/python3.6/dist-packages/torch/lib/libcudnn-900fef33.so.7.0.5

Versions of relevant libraries:
[pip3] numpy (1.14.2)
[pip3] torch (0.3.1)
[pip3] torchvision (0.2.0)
[conda] Could not collect
</code></pre></div>
<p dir="auto">Previously, my desktop was using libtorch 1.2.0 release and everything worked.<br>
After generating the exe, I wanted to take the notebook for on-site deployment. I installed libtorch on the notebook. At that time, it had been updated to 1.3.1 but reported the C4146 error. Even if I commented out everything in the main function, the error was still reported.<br>
In the end, I had to re-download 1.2.0 on my laptop to resolve this issue.<br>
I wonder if this problem is a bug?</p>