google-deepmind / scalable_agent

A TensorFlow implementation of Scalable Distributed Deep-RL with Importance Weighted Actor-Learner Architectures.
Apache License 2.0
981 stars 161 forks source link

Import sonnet is giving the error #47

Closed Pranav-India closed 3 years ago

Pranav-India commented 3 years ago

I have created venv and in that ,I am using TensorFlow version 1.9.0 when I try to run the experiment.py with 2 actors and 10 batch size it shows me the error given below what should I do?

Traceback (most recent call last): File "experiment.py", line 31, in import sonnet as snt File "/home/pranav/tf_1/lib/python3.6/site-packages/sonnet/init.py", line 21, in from sonnet import distribute File "/home/pranav/tf_1/lib/python3.6/site-packages/sonnet/distribute.py", line 21, in from sonnet.src.distribute.batch_norm import CrossReplicaBatchNorm File "/home/pranav/tf_1/lib/python3.6/site-packages/sonnet/src/distribute/batch_norm.py", line 22, in from sonnet.src import batch_norm File "/home/pranav/tf_1/lib/python3.6/site-packages/sonnet/src/batch_norm.py", line 22, in from sonnet.src import base File "/home/pranav/tf_1/lib/python3.6/site-packages/sonnet/src/base.py", line 37, in TFFunctionType = type(tf.function(lambda: None, autograph=False)) # pylint: disable=invalid-name AttributeError: module 'tensorflow' has no attribute 'function'

I know sonnet is build on top of tensorflow 2 but if I use tf2 then tf.contirb does not work

lespeholt commented 3 years ago

If you run a file with python just containing

import tensorflow as tf tf.function

what do you get?

Pranav-India commented 3 years ago

tf.version '1.9.0' tf.function Traceback (most recent call last): File "", line 1, in AttributeError: module 'tensorflow' has no attribute 'function' tf.function() Traceback (most recent call last): File "", line 1, in AttributeError: module 'tensorflow' has no attribute 'function'

lespeholt commented 3 years ago

It looks like your Sonnet version is too new. You could try and use a newer version of TF but can't guarantee the IMPALA code works if doing that.

Pranav-India commented 3 years ago

It does not I tried that I have 2 venvs one with tf 1.9.0 other with 2.4 IMPALA does not work there , I converted all the files to tf2 removed all the tf.contrib as it does not support the tf2 version but still IMPALA is not working there. do you know if it is possible to use older version of sonnet

If I run it with tf 2.4 and other codes updated using tf_upgrade_v2 then I get

import py_process File "/home/pranav/scalable_agent/py_process.py", line 186, in class PyProcessHook(tf.train.SessionRunHook): AttributeError: module 'tensorflow._api.v2.train' has no attribute 'SessionRunHook'

Error

lespeholt commented 3 years ago

Yes that will work:

https://github.com/deepmind/scalable_agent/blob/master/Dockerfile#L38

Pranav-India commented 3 years ago

ok thanks I will try that

Pranav-India commented 3 years ago

Hi @lespeholt thank you for your help that issue is solved but now I have received this error

WARNING:tensorflow:Running without dynamic batching. 2021-01-07 16:26:08.567726: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2021-01-07 16:26:08.569123: I tensorflow/core/distributed_runtime/rpc/grpc_channel.cc:215] Initialize GrpcChannelCache for job local -> {0 -> localhost:43601} 2021-01-07 16:26:08.569713: I tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc:334] Started server with target: grpc://localhost:43601 INFO:tensorflow:Creating actor 0 with level explore_goal_locations_small INFO:tensorflow:Creating actor 1 with level explore_goal_locations_small INFO:tensorflow:Creating MonitoredSession, is_chief True INFO:tensorflow:Create CheckpointSaverHook. WARNING:tensorflow:Issue encountered when serializing py_process_processes. Type is unsupported, or the types of the items don't match field type in CollectionDef. Note this is a warning and probably safe to ignore. 'PyProcess' object has no attribute 'name' INFO:tensorflow:Starting all processes. Traceback (most recent call last): File "experiment.py", line 700, in tf.app.run() File "/home/pranav/tf_1/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "experiment.py", line 694, in main train(action_set, level_names) File "experiment.py", line 587, in train hooks=[py_process.PyProcessHook()]) as session: File "/home/pranav/tf_1/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 415, in MonitoredTrainingSession stop_grace_period_secs=stop_grace_period_secs) File "/home/pranav/tf_1/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 826, in init stop_grace_period_secs=stop_grace_period_secs) File "/home/pranav/tf_1/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 542, in init h.begin() File "/home/pranav/reinforcement/scalable_agent/py_process.py", line 192, in begin tp.map(lambda p: p.start(), tf.get_collection(PyProcess.COLLECTION)) File "/usr/lib/python3.6/multiprocessing/pool.py", line 266, in map return self._map_async(func, iterable, mapstar, chunksize).get() File "/usr/lib/python3.6/multiprocessing/pool.py", line 644, in get raise self._value File "/usr/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, *kwds)) File "/usr/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar return list(map(args)) File "/home/pranav/reinforcement/scalable_agent/py_process.py", line 192, in tp.map(lambda p: p.start(), tf.get_collection(PyProcess.COLLECTION)) File "/home/pranav/reinforcement/scalable_agent/py_process.py", line 183, in start self._proxy._start() File "/home/pranav/reinforcement/scalable_agent/py_process.py", line 116, in _start raise result AttributeError: 'dict' object has no attribute 'iteritems'

I found that "Python 3 renamed dict.iteritems -> dict.items" but where have we used the dict.iteritems

Pranav-India commented 3 years ago

I found the files it is environment and in dmlab if we change them to dict, code works. Thank you.

lespeholt commented 3 years ago

Great :-)

Pranav-India commented 3 years ago

Hi @lespeholt

I just wanted to know where we have defined the neural network in these codes ( I am unable to understand the how algorithm is working ) like in A2C we have actor-critic networks and then we optimise that model(Neural Network) , I am not able to find the model here.

Also is there some forum or discussion group where I can ask my doubts about IMPALA . I am not able to find resources other than the paper so if you could point me somewhere that will be of a great help.

Thanks!