# Run only one job on local machine

**URL:** <https://aiida.discourse.group/t/run-only-one-job-on-local-machine/459>\
**Category:** Developer\
**Tags:** question, schedulers, aiida, plugin\
**Created:** [September 5, 2024, 5:45pm UTC](https://aiida.discourse.group/t/run-only-one-job-on-local-machine/459 "2024-09-05T17:45:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nkeilbart](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/nkeilbart/32/40_2.png) [@nkeilbart](https://aiida.discourse.group/u/nkeilbart)\
**Post date:** [September 5, 2024, 5:45pm UTC](https://aiida.discourse.group/t/run-only-one-job-on-local-machine/459/1 "2024-09-05T17:45:48Z")

</div>

Hello everyone,

I’ve recently been doing development on my local machine and at some point have several jobs that get launched in parallel from a single workchain instance. It seems someone had a similar question [Is there a Desktop Job Scheduler for MacOS - #3 by mbercx](https://aiida.discourse.group/t/is-there-a-desktop-job-scheduler-for-macos/95/3) and I’m wondering if there is a simpler way to just tell AiiDA to only run one JobCalc at a time? Otherwise, I’ll just deal with it or install a scheduler as mentioned. Thanks.

Nathan

---

<div class="post-metadata">

**Author:** ![Xing](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/xing/32/10_2.png) [@Xing](https://aiida.discourse.group/u/Xing)\
**Post date:** [September 5, 2024, 11:54pm UTC](https://aiida.discourse.group/t/run-only-one-job-on-local-machine/459/2 "2024-09-05T23:54:45Z")

</div>

If your **WorkChain is not nested** (i.e., it only submits `CalcJob`s and does not submit other WorkChains), and you’re only running **one WorkChain at a time** , you can follow this simple approach:

```bash
# Allocate one slot for the WorkChain itself and another for a CalcJob.
# Any additional CalcJobs will wait until a slot is available.
verdi config set daemon.worker_process_slots 2
verdi daemon restart

```

If your WorkChain is **nested** (i.e., it submits other WorkChains), you should increase the `worker_process_slots` based on the depth of nesting. For example, if your WorkChain submits two nested WorkChains, you will need **two more** slots to ensure smooth execution without blocking.

### **Important Note:**

This configuration should only be used for testing purposes. If the number of submitted WorkChains is equal to or greater than the available worker slots, the WorkChan can **deadlock** , as there will not be enough slots for all the processes to complete.

When moving to production, set the default value back for `worker_process_slots`:

```bash
verdi config set daemon.worker_process_slots 200
verdi daemon restart

```

---

<div class="post-metadata">

**Author:** ![jusong.yu](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/jusong.yu/32/3_2.png) [@jusong.yu](https://aiida.discourse.group/u/jusong.yu)\
**Post date:** [November 27, 2024, 10:59am UTC](https://aiida.discourse.group/t/run-only-one-job-on-local-machine/459/3 "2024-11-27T10:59:33Z")

</div>

> [@nkeilbart](#):
>
> I’ve recently been doing development on my local machine and at some point have several jobs that get launched in parallel from a single workchain instance.

I think it really depend on your goals.  
If during the development, you want to check if every pieces of workchain steps are working as expect by running it as a whole without starving your laptop resource, I’d recommend to not start daemon using `engine.run()` instead of `engine.submit()`.  
If you want to check that some steps in your workchain can spin up calculations in parallel but again not starving your laptop resources with hundreds of system processes. Using the approach mentioned by @Xing above.  
If you want to use your PC to run production workchain but not starving your laptop resources. I think it is better to have a scheduler and the hyperqueue is probably want you are looking for. We have `aiida-hyperqueue` plugin that developed from the team and being used also for `aiidalab-qe` deployment. (for how to set up this, I reply in another post by @nkeilbart at [Implementing the Flux scheduler from LLNL - #4 by jusong.yu](https://aiida.discourse.group/t/implementing-the-flux-scheduler-from-llnl/473/4))

---

<div class="post-metadata">

**Author:** ![ajjackson](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/ajjackson/32/347_2.png) [@ajjackson](https://aiida.discourse.group/u/ajjackson)\
**Post date:** [September 19, 2025, 12:58pm UTC](https://aiida.discourse.group/t/run-only-one-job-on-local-machine/459/4 "2025-09-19T12:58:52Z")

</div>

I recently encountered this problem and was pleasantly surprised by how easy it is to install a suitable slurm configuration on a modern Linux workstation. On a clean rocky linux machine my steps are (as root):

```bash
    # Install slurm
    dnf install -y slurm-slurmd slurm-slurmctld munge
    create-munge-key

    # Set correct number of CPUs in slurm config
    N_CPU=$(lscpu | grep '^CPU(s): ' | rev | cut --delimiter=' ' -f 1 | rev)
    MB_MEMORY=$(free -m | grep 'Mem:' | rev | cut -f 1 --delimiter=' ' | rev)
    
    sed -i "s/^NodeName=localhost.*$/NodeName=localhost CPUs=${N_CPU} State=UNKNOWN RealMemory=${MB_MEMORY}/" /etc/slurm/slurm.conf

    # # Enable slurm services
    systemctl --now enable munge
    systemctl --now enable slurmd
    systemctl --now enable slurmctld    

```

Then the computer configuration for AiiDA is something like

```yaml
    ---
    label: "local-slurm"
    description: "local slurm/MPI environment"
    hostname: "localhost"
    transport: "core.local"
    scheduler: "core.slurm"
    work_dir: "/home/myuser/.aiida_run"
    mpirun_command: "mpirun -np {tot_num_mpiprocs}"
    mpiprocs_per_machine: 30
    prepend_text: |
      export OMP_NUM_THREADS=1

```

That should then start automatically on reboot. The only “gotcha” is that if you tinker with the slurm.conf you need to restart `slurmd`. As you are the only user there is no need to go further into configuration of multiple queues, fairshare etc.!
