# Error when run PPOTrainer

**URL:** <https://discuss.ray.io/t/error-when-run-ppotrainer/3830>\
**Category:** RLlib\
**Created:** [October 15, 2021, 2:57pm UTC](https://discuss.ray.io/t/error-when-run-ppotrainer/3830 "2021-10-15T14:57:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mingjunwang88](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mingjunwang88/32/1619_2.png) [@mingjunwang88](https://discuss.ray.io/u/mingjunwang88)\
**Post date:** [October 15, 2021, 2:57pm UTC](https://discuss.ray.io/t/error-when-run-ppotrainer/3830/1 "2021-10-15T14:57:34Z")

</div>

This is code I run:  
config = DEFAULT\_CONFIG.copy()  
config[‘num\_workers’] = 1  
config[‘num\_sgd\_iter’] = 30  
config[‘sgd\_minibatch\_size’] = 128  
config[‘model’][‘fcnet\_hiddens’] = [100, 100]  
config[‘num\_cpus\_per\_worker’] = 1

agent = PPOTrainer(config, ‘CartPole-v1’)

I am having this error:

RayActorError: The actor died because of an error raised in its creation task, ray::RolloutWorker. **init** () (pid=127995, ip=172.16.35.94)  
AttributeError: ‘NoneType’ object has no attribute ‘config’

---

<div class="post-metadata">

**Author:** ![rusu24edward](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/rusu24edward/32/333_2.png) [@rusu24edward](https://discuss.ray.io/u/rusu24edward)\
**Post date:** [October 15, 2021, 3:19pm UTC](https://discuss.ray.io/t/error-when-run-ppotrainer/3830/2 "2021-10-15T15:19:16Z")

</div>

Can you provide more code? It looks like the Python interpreter is unable to find DEFAULT\_CONFIG. Have you imported it correctly?

---

<div class="post-metadata">

**Author:** ![mingjunwang88](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mingjunwang88/32/1619_2.png) [@mingjunwang88](https://discuss.ray.io/u/mingjunwang88)\
**Post date:** [October 15, 2021, 3:26pm UTC](https://discuss.ray.io/t/error-when-run-ppotrainer/3830/3 "2021-10-15T15:26:09Z")

</div>

This is import:  
from ray.rllib.agents.ppo import PPOTrainer, DEFAULT\_CONFIG  
from ray.tune.logger import pretty\_print  
import json  
import pandas as pd  
import gym

It looks normal. I tried the same code on Mac. It works fine. I am working a liunx on aws: here is the version: Linux ip-172-16-35-94 4.14.238-125.422.amzn1.x86\_64 #1 SMP Tue Jul 20 20:51:46 UTC 2021 x86\_64 x86\_64 x86\_64 GNU/Linux

It looks like all the trainers have the same problem. Anyone have any idea?

---

<div class="post-metadata">

**Author:** ![mannyv](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mannyv/32/606_2.png) [@mannyv](https://discuss.ray.io/u/mannyv)\
**Post date:** [October 15, 2021, 8:43pm UTC](https://discuss.ray.io/t/error-when-run-ppotrainer/3830/4 "2021-10-15T20:43:39Z")

</div>

Hi @mingjunwang88,

Is there more to the error log. I think is probably not the main error. I often see that when there is some other initial error.

What version of ray are you using? Here is a google colab with the setup you posted that is running OK.

> **[Google Colaboratory](https://colab.research.google.com/drive/1ylHBu-mrj3_SAF1VbpRXlEMrlf2a7pIo?usp=sharing)**

---

<div class="post-metadata">

**Author:** ![mingjunwang88](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mingjunwang88/32/1619_2.png) [@mingjunwang88](https://discuss.ray.io/u/mingjunwang88)\
**Post date:** [October 15, 2021, 9:15pm UTC](https://discuss.ray.io/t/error-when-run-ppotrainer/3830/5 "2021-10-15T21:15:24Z")

</div>

## Hi @mannyv : thanks for the responding! I did run the same script om Mac. it ran through. But I am running it on a AWS sagemaker instance. I installed as you did: pip install -u ray[all]. But it just failed before. Here is the complete log:

RayActorError Traceback (most recent call last)  
 in   
12 config[“num\_cpus\_per\_worker”] = 1  
13  
—\> 14 agent = PPOTrainer(config, “CartPole-v1”)

~/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/agents/trainer\_template.py in **init** (self, config, env, logger\_creator)  
135  
136 def **init** (self, config=None, env=None, logger\_creator=None):  
 → 137 Trainer. **init** (self, config, env, logger\_creator)  
138

~/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/agents/trainer.py in **init** (self, config, env, logger\_creator)  
609 logger\_creator = default\_logger\_creator  
610  
 → 611 super(). **init** (config, logger\_creator)  
612

~/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/tune/trainable.py in **init** (self, config, logger\_creator)  
104  
105 start\_time = time.time()  
 → 106 self.setup(copy.deepcopy(self.config))  
107 setup\_time = time.time() - start\_time  
108 if setup\_time \> SETUP\_TIME\_THRESHOLD:

~/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/agents/trainer\_template.py in setup(self, config)  
145 self.\_override\_all\_subkeys\_if\_type\_changes +=   
146 override\_all\_subkeys\_if\_type\_changes  
 → 147 super().setup(config)  
148  
149 def \_init(self, config: TrainerConfigDict,

~/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/agents/trainer.py in setup(self, config)  
762 logging.getLogger(“ray.rllib”).setLevel(self.config[“log\_level”])  
763  
 → 764 self.\_init(self.config, self.env\_creator)  
765  
766 # Evaluation setup.

~/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/agents/trainer\_template.py in \_init(self, config, env\_creator)  
174 policy\_class=self.\_policy\_class,  
175 config=config,  
 → 176 num\_workers=self.config[“num\_workers”])  
177 self.execution\_plan = execution\_plan  
178 try:

~/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/agents/trainer.py in \_make\_workers(self, env\_creator, validate\_env, policy\_class, config, num\_workers)  
850 trainer\_config=config,  
851 num\_workers=num\_workers,  
 → 852 logdir=self.logdir)  
853

~/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/evaluation/worker\_set.py in **init** (self, env\_creator, validate\_env, policy\_class, trainer\_config, num\_workers, logdir, \_setup)  
83 remote\_spaces = ray.get(self.remote\_workers(  
84 )[0].foreach\_policy.remote(  
—\> 85 lambda p, pid: (pid, p.observation\_space, p.action\_space)))  
86 spaces = {  
87 e[0]: (getattr(e[1], “original\_space”, e[1]), e[2])

~/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/\_private/client\_mode\_hook.py in wrapper(\*args, \*\*kwargs)  
87 if func. **name**!= “init” or is\_client\_mode\_enabled\_by\_default:  
88 return getattr(ray, func. **name** )(\*args, \*\*kwargs)  
—\> 89 return func(\*args, \*\*kwargs)  
90  
91 return wrapper

~/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/worker.py in get(object\_refs, timeout)  
1621 raise value.as\_instanceof\_cause()  
1622 else:  
 → 1623 raise value  
1624  
1625 if is\_individual\_id:

RayActorError: The actor died because of an error raised in its creation task, ray::RolloutWorker. **init** () (pid=105003, ip=172.16.35.94)  
AttributeError: ‘NoneType’ object has no attribute ‘config’

During handling of the above exception, another exception occurred:

ray::RolloutWorker. **init** () (pid=105003, ip=172.16.35.94)  
File “/home/ec2-user/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/evaluation/rollout\_worker.py”, line 564, in **init**  
devices = get\_tf\_gpu\_devices()  
File “/home/ec2-user/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/utils/tf\_ops.py”, line 53, in get\_gpu\_devices  
devices = tf.config.experimental.list\_physical\_devices()  
AttributeError: ‘NoneType’ object has no attribute ‘config’  
(pid=105003) 2021-10-15 21:07:06,987 ERROR worker.py:428 – Exception raised in creation task: The actor died because of an error raised in its creation task, ray::RolloutWorker. **init** () (pid=105003, ip=172.16.35.94)  
(pid=105003) AttributeError: ‘NoneType’ object has no attribute ‘config’  
(pid=105003)  
(pid=105003) During handling of the above exception, another exception occurred:  
(pid=105003)  
(pid=105003) ray::RolloutWorker. **init** () (pid=105003, ip=172.16.35.94)  
(pid=105003) File “/home/ec2-user/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/evaluation/rollout\_worker.py”, line 564, in **init**  
(pid=105003) devices = get\_tf\_gpu\_devices()  
(pid=105003) File “/home/ec2-user/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/utils/tf\_ops.py”, line 53, in get\_gpu\_devices  
(pid=105003) devices = tf.config.experimental.list\_physical\_devices()  
(pid=105003) AttributeError: ‘NoneType’ object has no attribute ‘config’

---

<div class="post-metadata">

**Author:** ![mannyv](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mannyv/32/606_2.png) [@mannyv](https://discuss.ray.io/u/mannyv)\
**Post date:** [October 15, 2021, 9:18pm UTC](https://discuss.ray.io/t/error-when-run-ppotrainer/3830/6 "2021-10-15T21:18:55Z")

</div>

Tensorflow is not installed.

```auto
(pid=105003) devices = tf.config.experimental.list_physical_devices()
(pid=105003) AttributeError: ‘NoneType’ object has no attribute ‘config’

``
```

---

<div class="post-metadata">

**Author:** ![mingjunwang88](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mingjunwang88/32/1619_2.png) [@mingjunwang88](https://discuss.ray.io/u/mingjunwang88)\
**Post date:** [October 15, 2021, 9:42pm UTC](https://discuss.ray.io/t/error-when-run-ppotrainer/3830/7 "2021-10-15T21:42:00Z")

</div>

## @mannyv : I just install tensorflow. But still seeing this at the beginning: (pid=120014) 2021-10-15 21:38:47,045 ERROR worker.py:428 – Exception raised in creation task: The actor died because of an error raised in its creation task, ray::RolloutWorker. **init** () (pid=120014, ip=172.16.35.94) (pid=120014) File “/home/ec2-user/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/evaluation/rollout\_worker.py”, line 587, in **init** (pid=120014) seed=seed) (pid=120014) File “/home/ec2-user/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/evaluation/rollout\_worker.py”, line 1383, in \_build\_policy\_map (pid=120014) conf, merged\_conf) (pid=120014) File “/home/ec2-user/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/policy/policy\_map.py”, line 123, in create\_policy (pid=120014) sess = self.session\_creator() (pid=120014) File “/home/ec2-user/anaconda3/envs/pytorch\_p36/lib/python3.6/site-packages/ray/rllib/evaluation/worker\_set.py”, line 316, in session\_creator (pid=120014) return tf1.Session( (pid=120014) AttributeError: ‘NoneType’ object has no attribute ‘Session’

Why this time it is tf1?

---

<div class="post-metadata">

**Author:** ![mingjunwang88](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mingjunwang88/32/1619_2.png) [@mingjunwang88](https://discuss.ray.io/u/mingjunwang88)\
**Post date:** [October 16, 2021, 3:14pm UTC](https://discuss.ray.io/t/error-when-run-ppotrainer/3830/8 "2021-10-16T15:14:22Z")

</div>

@mannyv : it actually works now. I believe it was something wrong with the installation of tensorflow. Thanks of the help!
