If you run pytorch ops on CPU you may get spammed with this extremely annoying warning about NNPack:
#!/usr/bin/env python3
import torch as th
import torch.nn as nn
conv = nn.Conv2d(3, 3, 3)
# cpu forward here will spam an nnpack warning
for i in range(10):
x = conv(th.ones(1, 3, 3, 3))./nnpack_repro.py
[W517 18:02:54.644240235 NNPACK.cpp:57] Could not initialize NNPACK! Reason: Unsupported hardware.
[W517 18:02:54.650463229 NNPACK.cpp:57] Could not initialize NNPACK! Reason: Unsupported hardware.
[W517 18:02:54.650796375 NNPACK.cpp:57] Could not initialize NNPACK! Reason: Unsupported hardware.
[W517 18:02:54.651290323 NNPACK.cpp:57] Could not initialize NNPACK! Reason: Unsupported hardware.
[W517 18:02:54.651739820 NNPACK.cpp:57] Could not initialize NNPACK! Reason: Unsupported hardware.
[W517 18:02:54.652140107 NNPACK.cpp:57] Could not initialize NNPACK! Reason: Unsupported hardware.
[W517 18:02:54.652370471 NNPACK.cpp:57] Could not initialize NNPACK! Reason: Unsupported hardware.
[W517 18:02:54.652827388 NNPACK.cpp:57] Could not initialize NNPACK! Reason: Unsupported hardware.
[W517 18:02:54.653462109 NNPACK.cpp:57] Could not initialize NNPACK! Reason: Unsupported hardware.
[W517 18:02:54.653915717 NNPACK.cpp:57] Could not initialize NNPACK! Reason: Unsupported hardware.
This warning is emitted by C++ code so you can't suppress it with warnings or any usual python method.
The fix is to tell PyTorch to disable NNPack entirely:
import torch as th
th.backends.nnpack.set_flags(False)