facebookresearch / hanabi_SAD

Simplified Action Decoder for Deep Multi-Agent Reinforcement Learning
Other
97 stars 35 forks source link

Unable to run due to python to c++ cast error #8

Closed isabel-b closed 4 years ago

isabel-b commented 4 years ago

Hi Hengyuan,

Sorry to bother you - I'm trying to run this code, however when I run any of the scripts I get an error 'RuntimeError: Unable to cast Python instance of type <class 'torch._C.ScriptModule'> to C++ type 'torch::jit::script::Module'. The error occurs when attempting to instantiate a ModelLocker (in rela/modellocker.h, line 24: `models.pushback(pyModels[i].attr("_c").cast<TorchJitModel*>());` ). If you have time, do you know why this could be occuring? I think I followed all instructions in the repo correctly.

Thanks, Isabel

hengyuan-hu commented 4 years ago

In principle this is caused by version mismatch between pybind used by pytorch and pybind used in this repo. Are you sure that both your pytorch and pybind (the submodule in this repo) are of the correct version?

hengyuan-hu commented 4 years ago

Have you installed pybind with pip or something else before? Can you try in a different folder:

import pybind
pybind.__version__
isabel-b commented 4 years ago

Thanks very much! It turned out that pytorch version v1.3.0 uses a different pybind11 commit (25abf7e) to the one in this repo (a1b71df). It works now that I've checked out the a1b71df commit in the pytorch repo.

ravihammond commented 2 years ago

Thanks very much! It turned out that pytorch version v1.3.0 uses a different pybind11 commit (25abf7e) to the one in this repo (a1b71df). It works now that I've checked out the a1b71df commit in the pytorch repo.

Hi @isabel-b, how did you figure out that pytorch version v1.3.0 uses that specific pybind11 commit? I'm using a different pytorch version and am trying to figure out what pybind11 commit I need to use.

Any help would be greatly appreciated, thanks so much!