google-deepmind / open_spiel

OpenSpiel is a collection of environments and algorithms for research in general reinforcement learning and search/planning in games.
Apache License 2.0
4.28k stars 937 forks source link

Issue building docker image with Dockerfile.base #1293

Open giogix2 opened 2 days ago

giogix2 commented 2 days ago

I've used the docker installation for some local test following the instructions in Installing via Docker. I get an error when the Python requirements are installed, specifically:

1.035 Collecting ml-collections>=0.1.1 (from -r requirements.txt (line 17))
1.056   Downloading ml_collections-0.1.1.tar.gz (77 kB)
1.081   Preparing metadata (setup.py): started
1.146   Preparing metadata (setup.py): finished with status 'error'
1.149   error: subprocess-exited-with-error
1.149   
1.149   × python setup.py egg_info did not run successfully.
1.149   │ exit code: 1
1.149   ╰─> [10 lines of output]
1.149       Traceback (most recent call last):
1.149         File "<string>", line 2, in <module>
1.149         File "<pip-setuptools-caller>", line 14, in <module>
1.149         File "/usr/local/lib/python3.8/dist-packages/setuptools/__init__.py", line 27, in <module>
1.149           from .dist import Distribution
1.149         File "/usr/local/lib/python3.8/dist-packages/setuptools/dist.py", line 30, in <module>
1.149           from . import (
1.149         File "/usr/local/lib/python3.8/dist-packages/setuptools/_entry_points.py", line 45, in <module>
1.149           def validate(eps: metadata.EntryPoints):
1.149       AttributeError: module 'importlib_metadata' has no attribute 'EntryPoints'
1.149       [end of output]
1.149   
1.149   note: This error originates from a subprocess, and is likely not a problem with pip.
1.151 error: metadata-generation-failed
1.151 
1.151 × Encountered error while generating package metadata.
1.151 ╰─> See above for output.
1.151 
1.151 note: This is an issue with the package mentioned above, not pip.
1.151 hint: See above for details.

I was able to solve the problem forcing to reinstall importlib_metadata, as explained in this Stackoverflow post. Basically, I added the command RUN pip install importlib_metadata --force-reinstall before this line in the Dockerfile.base. Is this a known issue? I'm sure there's a more elegant way to fix this.

Unfortunately, after fixing this I get other compliler related issues. In particular, the compiler fails with spiel_utils.cc throwing the following complains:

3.450 In file included from /repo/open_spiel/spiel_utils.cc:15:
3.452 /repo/open_spiel/../open_spiel/spiel_utils.h:51:59: error: no template named 'unique_ptr' in namespace 'std'
3.452 std::ostream& operator<<(std::ostream& stream, const std::unique_ptr<T>& v);
3.452                                                      ~~~~~^
3.463 /repo/open_spiel/../open_spiel/spiel_utils.h:88:59: error: no template named 'unique_ptr' in namespace 'std'
3.463 std::ostream& operator<<(std::ostream& stream, const std::unique_ptr<T>& v) {

My clang++ version is 15.0.0. This issue can be easily solved by adding the import #include <memory> in spiel_utils.h. I'm sure this is an issue specific with my compliler, but let me know if I should create a merge request adding this line in spiel_utils.h.

lanctot commented 2 days ago

Hi @giogix2 ,

We don't maintain the docker file, so someone may have run into this before but it's the first we're hearing about it. Thanks for reporting!

I'd encourage you to submit two PRs:

Appreciate this, thanks!