# Dreamer V3 on custom environment

**URL:** <https://discuss.ray.io/t/dreamer-v3-on-custom-environment/13627>\
**Category:** Uncategorized\
**Created:** [February 3, 2024, 3:42pm UTC](https://discuss.ray.io/t/dreamer-v3-on-custom-environment/13627 "2024-02-03T15:42:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ng\_angus](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/ng_angus/32/5693_2.png) [@ng\_angus](https://discuss.ray.io/u/ng_angus)\
**Post date:** [February 3, 2024, 3:42pm UTC](https://discuss.ray.io/t/dreamer-v3-on-custom-environment/13627/1 "2024-02-03T15:42:09Z")

</div>

Hi all,  
I am trying to implement dreamer v3 on my custom environment with  
action\_space = gym.spaces.Box(low=-np.inf, high=np.inf, shape=(64,), dtype=np.float32)  
observation\_space = gym.spaces.Box(low=-np.inf, high=np.inf, shape=(204,), dtype=np.float32)

The following errors were raised  
AttributeError: Exception encountered when calling layer ‘dreamer\_model’  
AttributeError: Exception encountered when calling layer ‘dynamics\_predictor’  
AttributeError: Exception encountered when calling layer ‘z32x32’  
Call arguments received by layer ‘dreamer\_model’ (type DreamerModel):  
• inputs=None  
• observations=tf.Tensor(shape=(1, 64, 204), dtype=float32)  
• actions=tf.Tensor(shape=(1, 64, 64), dtype=float32)  
• is\_first=tf.Tensor(shape=(1, 64), dtype=bool)  
• start\_is\_terminated\_BxT=tf.Tensor(shape=(64,), dtype=bool)

Not too sure whether this might be because of my differ obs and action space instead of the standard 64,64,3, I have tried to use the dreamer catalogclass but it is still not working, any ideas?

many thanks

---

<div class="post-metadata">

**Author:** ![kaige\_yang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kaige_yang/32/5497_2.png) [@kaige\_yang](https://discuss.ray.io/u/kaige_yang)\
**Post date:** [February 4, 2024, 3:28am UTC](https://discuss.ray.io/t/dreamer-v3-on-custom-environment/13627/2 "2024-02-04T03:28:53Z")

</div>

pip install tensorflow-probability

and then run your script again

---

<div class="post-metadata">

**Author:** ![ng\_angus](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/ng_angus/32/5693_2.png) [@ng\_angus](https://discuss.ray.io/u/ng_angus)\
**Post date:** [February 4, 2024, 11:08pm UTC](https://discuss.ray.io/t/dreamer-v3-on-custom-environment/13627/3 "2024-02-04T23:08:01Z")

</div>

Thank you very much for your response  
My code is working now, but for some reason, tensorflow is not using my GPU at all, I installed tf with GPU using pip

print(tf.config.list\_physical\_devices(‘GPU’))  
returns [PhysicalDevice(name=‘/physical\_device:GPU:0’, device\_type=‘GPU’)]

I also set num\_gpu=1 in ray.init  
and have set .resources(num\_gpus=int(os.environ.get(“RLLIB\_NUM\_GPUS”, “1”))) to my config

when I run the code, ray does say GPU 0/1.0, but the code is simply not using it at all,  
any ideas why? thank you

---

<div class="post-metadata">

**Author:** ![ng\_angus](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/ng_angus/32/5693_2.png) [@ng\_angus](https://discuss.ray.io/u/ng_angus)\
**Post date:** [February 5, 2024, 5:25pm UTC](https://discuss.ray.io/t/dreamer-v3-on-custom-environment/13627/5 "2024-02-05T17:25:34Z")

</div>

Sorry for bothering you again  
when I call config.build(), the problem recurs,  
but it’s fine if I call tune.Tuner(trainable=“DreamerV3”,  
param\_space=config)

Do you have any idea why?  
I want to define a train function with config.build() so that I can pass it to tune\_with\_resources, thanks
