geek-ai / MAgent

A Platform for Many-Agent Reinforcement Learning
MIT License
1.68k stars 332 forks source link

Can't run it in Linux #47

Open axi345 opened 5 years ago

axi345 commented 5 years ago

I used Ubuntu 14.02 and Anaconda with Python 3.5.2 to run this project. I downloaded this repository and run these commands:

cd MAgent sudo apt-get install cmake libboost-system-dev libjsoncpp-dev libwebsocketpp-dev bash build.sh export PYTHONPATH=$(pwd)/python:$PYTHONPATH

But there raised some errors and I couldn't install the python package successfully. So I copied the file "Magent" to my python project and used pycharm to mark the "Python" file in it as the Sources Root. When I run the file "api_demo.py", it showed some error massages:

/home/sean/anaconda3/bin/python3.6 /home/sean/DRL/MAgent/examples/train_pursuit.py Traceback (most recent call last): File "/home/sean/DRL/MAgent/examples/train_pursuit.py", line 11, in import magent File "/home/sean/DRL/MAgent/python/magent/init.py", line 2, in from . import utility File "/home/sean/DRL/MAgent/python/magent/utility.py", line 12, in from magent.builtin.rule_model import RandomActor File "/home/sean/DRL/MAgent/python/magent/builtin/rule_model/init.py", line 2, in from .rush import RushPredator File "/home/sean/DRL/MAgent/python/magent/builtin/rule_model/rush.py", line 7, in from magent.c_lib import _LIB, as_int32_c_array, as_float_c_array File "/home/sean/DRL/MAgent/python/magent/c_lib.py", line 42, in _LIB = _load_lib() File "/home/sean/DRL/MAgent/python/magent/c_lib.py", line 21, in _load_lib lib = ctypes.CDLL(path_to_so_file, ctypes.RTLD_GLOBAL) File "/home/sean/anaconda3/lib/python3.6/ctypes/init.py", line 348, in init self._handle = _dlopen(self._name, mode) OSError: /home/sean/DRL/MAgent/python/magent/../../build/libmagent.so: cannot open shared object file: No such file or directory

Process finished with exit code 1

It seems that my file miss some resources. But I use files completely copied from git. Maybe I missed some steps. I need some help to use the repository. o_o

Kipsora commented 5 years ago

It seems that the build process was failed and thus libmagent.so did not exist. Can you provide the build messages as well?

axi345 commented 5 years ago

Thank you for your reply. All the build message is shown in below: sean@sean-Lenovo:~$ cd MAgent sean@sean-Lenovo:~/MAgent$ sudo apt-get install cmake libboost-system-dev libjsoncpp-dev libwebsocketpp-dev sudo: unable to resolve host sean-Lenovo [sudo] password for sean: Reading package lists... Done Building dependency tree
Reading state information... Done E: Unable to locate package libwebsocketpp-dev sean@sean-Lenovo:~/MAgent$ sean@sean-Lenovo:~/MAgent$ bash build.sh -- Configuring done -- Generating done -- Build files have been written to: /home/sean/MAgent/build [ 6%] [ 6%] Building CXX object CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o Building CXX object CMakeFiles/render.dir/src/render/backend/websocket.cc.o In file included from /home/sean/MAgent/src/render/backend/websocket.cc:1:0: /home/sean/MAgent/src/render/backend/websocket.h:4:53: fatal error: websocketpp/config/asio_no_tls_client.hpp: No such file or directory

include <websocketpp/config/asio_no_tls_client.hpp>

                                                 ^

compilation terminated. make[2]: [CMakeFiles/render.dir/src/render/backend/websocket.cc.o] Error 1 make[1]: [CMakeFiles/render.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [ 10%] Building CXX object CMakeFiles/magent.dir/src/discrete_snake/DiscreteSnake.cc.o /home/sean/MAgent/src/discrete_snake/DiscreteSnake.cc:165:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]

pragma omp declare reduction (merge : std::vector<Agent*> : omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end()))

^ /home/sean/MAgent/src/discrete_snake/DiscreteSnake.cc:166:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]

pragma omp declare reduction (merge : std::vector<Food*> : omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end()))

^ /home/sean/MAgent/src/discrete_snake/DiscreteSnake.cc:167:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]

pragma omp declare reduction (merge : std::set : omp_out.insert(omp_in.begin(), omp_in.end()))

^ /home/sean/MAgent/src/gridworld/GridWorld.cc:457:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]

pragma omp declare reduction (merge : std::vector : omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end()))

^ /home/sean/MAgent/src/discrete_snake/DiscreteSnake.cc: In member function ‘virtual void magent::discrete_snake::DiscreteSnake::step(int)’: /home/sean/MAgent/src/discrete_snake/DiscreteSnake.cc:216:40: error: expected ‘+’, ‘’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’

pragma omp parallel for reduction(merge: dead_list) reduction(merge: eat_list) reduction(merge: double_head_list) reduction(+: added_length)

                                    ^

/home/sean/MAgent/src/discrete_snake/DiscreteSnake.cc:216:68: error: expected ‘+’, ‘*’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’

pragma omp parallel for reduction(merge: dead_list) reduction(merge: eat_list) reduction(merge: double_head_list) reduction(+: added_length)

                                                                ^

/home/sean/MAgent/src/discrete_snake/DiscreteSnake.cc:216:95: error: expected ‘+’, ‘*’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’

pragma omp parallel for reduction(merge: dead_list) reduction(merge: eat_list) reduction(merge: double_head_list) reduction(+: added_length)

                                                                                           ^

/home/sean/MAgent/src/discrete_snake/DiscreteSnake.cc:261:40: error: expected ‘+’, ‘*’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’

pragma omp parallel for reduction(merge: new_foods)

                                    ^

make[2]: [CMakeFiles/magent.dir/src/discrete_snake/DiscreteSnake.cc.o] Error 1 make[2]: Waiting for unfinished jobs.... /home/sean/MAgent/src/gridworld/GridWorld.cc: In member function ‘virtual void magent::gridworld::GridWorld::step(int)’: /home/sean/MAgent/src/gridworld/GridWorld.cc:475:40: error: expected ‘+’, ‘’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’

pragma omp parallel for reduction(merge: render_attack_buffer)

                                    ^

make[2]: [CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o] Error 1 make[1]: [CMakeFiles/magent.dir/all] Error 2 make: *** [all] Error 2 sean@sean-Lenovo:~/MAgent$

Kipsora commented 5 years ago

The build log shows that your C++ compiler does not support LLVM and hence the compilation cannot be completed. You may manually upgrade your C++ compiler and rebuild the project.

You may also refer my environment:

$ uname -a
Linux Kipsora-All-Series 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Mon Dec 4
15:57:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609

$ cmake --version
cmake version 3.5.1

By the way, I've also seen that you have not installed websocketpp which is not released on Ubuntu 14 so I am afraid that it would be annoying to build MAgent (refer here).