hust-diangroup / ns3-ai

Enable the interaction between ns-3 and popular frameworks using Python, which mean you can train and test your AI algorithms in ns-3 without changing any frameworks you are using now!
GNU General Public License v2.0
220 stars 80 forks source link

pybind11::memoryview "from_memory" error #110

Open mkris0714 opened 6 months ago

mkris0714 commented 6 months ago

For communication between gym and ns3, I installed the ns3-ai.

but, during the process of ns3 building, the below error was occurred in spite of the installed pybind11 via apt-get.

I have solved the error by re-installing pybind11 via pip global commands: pip install "pybind11[global]"

Why does the error occur ?

[ 1%] Building CXX object src/antenna/CMakeFiles/libantenna-obj.dir/model/cosine-antenna-model.cc.o [ 1%] Building CXX object src/core/CMakeFiles/libcore-obj.dir/helper/csv-reader.cc.o [ 1%] Building CXX object src/antenna/CMakeFiles/libantenna-obj.dir/model/isotropic-antenna-model.cc.o /root/impl_source/netai_impl/learning/environments/ns-allinone-3.38/ns-3.38/contrib/ai/model/gym-interface/py/msg_py_binding.cc: In lambda function: /root/impl_source/netai_impl/learning/environments/ns-allinone-3.38/ns-3.38/contrib/ai/model/gym-interface/py/msg_py_binding.cc:36:41: error: ‘from_memory’ is not a member of ‘pybind11::memoryview’ 36 | return py::memoryview::from_memory((void)msg.buffer, msg.size); | ^~~ /root/impl_source/netai_impl/learning/environments/ns-allinone-3.38/ns-3.38/contrib/ai/model/gym-interface/py/msg_py_binding.cc: In lambda function: /root/impl_source/netai_impl/learning/environments/ns-allinone-3.38/ns-3.38/contrib/ai/model/gym-interface/py/msg_py_binding.cc:40:36: error: ‘from_memory’ is not a member of ‘pybind11::memoryview’ 40 | return py::memoryview::from_memory((void)msg.buffer, MSG_BUFFER_SIZE);

pjzklcb commented 6 months ago

This may due to the version of pybind11. Which version of pybind11 are you using? I met the same problem when I work on Ubuntu 20.04 with the default pybind11-2.4.3. I fix the problem by download and install pybind11-2.9.1, which is the default version on Ubuntu 22.04.