# How to set Environment Variable per node?

**URL:** <https://discuss.ray.io/t/how-to-set-environment-variable-per-node/7380>\
**Category:** Ray Core\
**Created:** [August 30, 2022, 11:24am UTC](https://discuss.ray.io/t/how-to-set-environment-variable-per-node/7380 "2022-08-30T11:24:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shyampatel](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@shyampatel](https://discuss.ray.io/u/shyampatel)\
**Post date:** [August 30, 2022, 11:24am UTC](https://discuss.ray.io/t/how-to-set-environment-variable-per-node/7380/1 "2022-08-30T11:24:16Z")

</div>

- High: It blocks me to complete my task.

I am running ray cluster using `cluster.yaml` file. I have 3 worker node and one head node. How can I set environment variable per node?

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [August 30, 2022, 4:53pm UTC](https://discuss.ray.io/t/how-to-set-environment-variable-per-node/7380/2 "2022-08-30T16:53:24Z")

</div>

Do you want to set different env var per node?

---

<div class="post-metadata">

**Author:** ![shyampatel](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@shyampatel](https://discuss.ray.io/u/shyampatel)\
**Post date:** [August 31, 2022, 2:03pm UTC](https://discuss.ray.io/t/how-to-set-environment-variable-per-node/7380/3 "2022-08-31T14:03:32Z")

</div>

Yes.  
Actually, I want to set different values of variables for each node.

---

<div class="post-metadata">

**Author:** ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)\
**Post date:** [August 31, 2022, 5:37pm UTC](https://discuss.ray.io/t/how-to-set-environment-variable-per-node/7380/4 "2022-08-31T17:37:07Z")

</div>

Yea, it’s doable.

Basically you need to specify a node type for each worker node. Under the config for each node type, you can specify `worker_setup_commands` ([Cluster YAML Configuration Options — Ray 2.0.0](https://docs.ray.io/en/latest/cluster/vms/references/ray-cluster-configuration.html#available-node-types-node-type-name-node-type-worker-setup-commands)) like `ENV_VAR1=0 ray start --address=$RAY_HEAD_IP:6379 --object-manager-port=8076 --object-store-memory=80000000000`. Or if you are using docker, you can use the `run_options` field and set “-e” arguments that will be passed to docker run.

---

<div class="post-metadata">

**Author:** ![shyampatel](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@shyampatel](https://discuss.ray.io/u/shyampatel)\
**Post date:** [September 1, 2022, 5:49am UTC](https://discuss.ray.io/t/how-to-set-environment-variable-per-node/7380/5 "2022-09-01T05:49:42Z")

</div>

Thanks for resolving the query @jjyao .
