There are three typical causes of such a thing:

you made a debug build, or one without avx,
you are missing some back end library in libtorch, or
the threading setup is missing.

The first two won’t happen when you use libtorch from the PyTorch installation.
For the third, you can debug this by looking at top while running your programming to see if CPU goes over 100%.
Best regards
Thomas