'torch.classes' has no attribute 'load_library'

I was following the instructions here to create a custom c++ class and use it in Python with TouchScript. But I’m having trouble loading the library. Here’s my code and the stacktrace:

>>> import torch
>>> torch.classes.load_library('Array.cp37-win_amd64.pyd')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'torch.classes' has no attribute 'load_library'

The custom operator tutorial worked fine for me: I can load the script properly. Does anyone know the reason behind this error or how to solve it?


Could you print your PyTorch version via print(torch.__version__)?
The method seems to have landed on Jan 23rd (PR), so you might want to install a nightly build.

Thanks for replying.
I’m using pytorch 1.4.0 on cpu so I guess this isn’t supported. Still, I think that the tutorial was there long before Jan 23rd, am I correct? If I’m correct, what was used to load classes then?

i meet the same error in run .py file, i want to konw the solution when you work out the problem.Thanks.