'How to allocate node by node with slurm?
My goal : I would like to launch multiple codes, nodes by nodes and allocated 100% each nodes
epic* up infinite 4 alloc lio[1-2]
And what I get :
epic* up infinite 4 mix lio[1-3,5]
my script :
#!/bin/bash
#SBATCH -A pt
#SBATCH -p epic
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=16
#SBATCH -J concentration
#SBATCH --array=1-4
. /usr/share/Modules/init/bash
module purge
module load openmpi-gcc/4.0.4-pmix_v2
MAXLEVEL=14
Ranf=8000
case $SLURM_ARRAY_TASK_ID in
1) phi='0.01'
;;
2) phi='0.008'
;;
3) phi='0.005'
;;
4) phi='0.001'
;;
esac
mkdir RBnf-P=$phi
cp RBnf `pwd`/RBnf-P=$phi/
cd RBnf-P=$phi
srun --mpi=pmix_v2 -J Ra${phi} ./RBnf $Ranf $MAXLEVEL $Phi
Each computation needs 16 process per node and each node have 32 process.
I have 4 computations to make.
My question : How can I allocated at 100% only 2 nodes ?
Because my script will use 4 nodes. So each nodes will be used at 50% of it's capacity (4 * 16/32). I would like to have my codes running on only 2 nodes at 100% of their capacity (2 * 32/32). With this script slurm will allocate an other node instead of fill a node already used. That's why I have "mix" node and I want only 2 nodes "alloc".
Have you any ideas ?
Solution 1:[1]
The primary issues is with the dependency array that you passed into your useEffect call.
useEffect(() => {
const getRevenue = async () => {
try {
const res = ...;
setRevenue(res.data);
setDifference((res.data[1].total * 100) / (res.data[0].total - 100));
} catch (error) {
...
}
};
getRevenue();
}, [difference]);
You have [difference] when it should be [setRevenue, setDifference]. By including difference you are telling react that it needs to run this effect when difference changes HOWEVER you are also calling setDifference here which changes the value of difference. This will infinitely loop. Changing the dependencies to [setRevenue, setDifference] will resolve the infinite loop problem.
useEffect(() => {
const getRevenue = async () => {
try {
const res = ...;
setRevenue(res.data);
setDifference((res.data[1].total * 100) / (res.data[0].total - 100));
} catch (error) {
...
}
};
getRevenue();
}, [setRevenue, setDifference]);
The second thing (which debatably isn't even an issue) is that inside useEffect you are calling setRevenue and setDifference in an asynchronous context. In versions of React before the new beta version (18) react doesn't batch these two state updates. This question explains it really well imo.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | kyle |
