# \`num\_processes == 1\` even when I set it to \`--num\_processes 2\`

**URL:** <https://discuss.huggingface.co/t/num-processes-1-even-when-i-set-it-to-num-processes-2/40122>\
**Category:** 🤗Accelerate\
**Created:** [May 17, 2023, 4:42am UTC](https://discuss.huggingface.co/t/num-processes-1-even-when-i-set-it-to-num-processes-2/40122 "2023-05-17T04:42:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanswyi](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@seanswyi](https://discuss.huggingface.co/u/seanswyi)\
**Post date:** [May 17, 2023, 4:42am UTC](https://discuss.huggingface.co/t/num-processes-1-even-when-i-set-it-to-num-processes-2/40122/1 "2023-05-17T04:42:26Z")

</div>

I have a Python script that I’m running with HuggingFace Accelerate. I also have a total of 4 GPUs but only wish to use 2. The command I’m running looks like this: `accelerate launch --num_processes 2 script.py`. However, whenever I run it this way, it says that the `num_processes` is 1. It seems as of now that I can only use either all of the GPUs or 1. Is there anything that I’m doing wrong or should look into further?

---

<div class="post-metadata">

**Author:** ![muellerzr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/muellerzr/32/21583_2.png) [@muellerzr](https://discuss.huggingface.co/u/muellerzr)\
**Post date:** [May 17, 2023, 11:25am UTC](https://discuss.huggingface.co/t/num-processes-1-even-when-i-set-it-to-num-processes-2/40122/2 "2023-05-17T11:25:00Z")

</div>

Try passing in `--multi_gpu` as well

---

<div class="post-metadata">

**Author:** ![seanswyi](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@seanswyi](https://discuss.huggingface.co/u/seanswyi)\
**Post date:** [May 17, 2023, 2:15pm UTC](https://discuss.huggingface.co/t/num-processes-1-even-when-i-set-it-to-num-processes-2/40122/3 "2023-05-17T14:15:22Z")

</div>

I tried that and it didn’t work. It also wouldn’t make sense though, would it? Not passing any argument makes the process grab all of the GPUs by default, so I don’t understand how specifying the number of processes would change that.

---

<div class="post-metadata">

**Author:** ![muellerzr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/muellerzr/32/21583_2.png) [@muellerzr](https://discuss.huggingface.co/u/muellerzr)\
**Post date:** [May 17, 2023, 2:25pm UTC](https://discuss.huggingface.co/t/num-processes-1-even-when-i-set-it-to-num-processes-2/40122/4 "2023-05-17T14:25:01Z")

</div>

Can you provide the output of `nvidia-smi`, and the full output of just doing `accelerate launch myscript.py`?

---

<div class="post-metadata">

**Author:** ![seanswyi](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@seanswyi](https://discuss.huggingface.co/u/seanswyi)\
**Post date:** [May 18, 2023, 9:21am UTC](https://discuss.huggingface.co/t/num-processes-1-even-when-i-set-it-to-num-processes-2/40122/5 "2023-05-18T09:21:16Z")

</div>

Funny, now when I tried passing `--multi_gpu` as well again, it seems to be working. Not sure what went wrong before but I assume this is how you do it.

Do you know if there’s a reason why `--multi_gpu` is not set to True by default?

---

<div class="post-metadata">

**Author:** ![muellerzr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/muellerzr/32/21583_2.png) [@muellerzr](https://discuss.huggingface.co/u/muellerzr)\
**Post date:** [May 18, 2023, 11:51am UTC](https://discuss.huggingface.co/t/num-processes-1-even-when-i-set-it-to-num-processes-2/40122/6 "2023-05-18T11:51:47Z")

</div>

> [@seanswyi](#):
>
> Do you know if there’s a reason why `--multi_gpu` is not set to True by default?

Nope, going to be looking into enabling it 🙂
