'Server with multi-processor, how to launch code

I don't have a big knowledge in hardware, GPU and CPU so I'm trying to create it. I have a server with N processor, the description for each of them is more or less the following one:

processor   : 63
vendor_id   : AuthenticAMD
cpu family  : 25
model       : 1
model name  : AMD EPYC 7313 16-Core Processor
stepping    : 1
microcode   : 0xa001119
cpu MHz     : 3724.322
cache size  : 512 KB
physical id : 1
siblings    : 32
core id     : 15
cpu cores   : 16
apicid      : 63
initial apicid  : 63
fpu     : yes
fpu_exception   : yes
cpuid level : 16
wp      : yes

I don't have a job scheduler, so I'm using tmux or screen to deal with my code. My question is, how can I deal with the processor and use like 3 of them, or less or more, and run my python code? I'm very confused about that.

Thank you



Solution 1:[1]

You probably want to divide your work into tasks that can run independently from each other and then have them in their own processes via forking (if they don't need to communicate with each other and e.g. just store their results somewhere on disk) or create threads to run them.

A single thread will always only use a single CPU, you need multiple threads to use more CPUs. Each process has at least one thread, that's why creating multiple processes would work, too.

Since you mention tmux, maybe bash's job control can help you - short example would be my_script.py input_file & my_script.py another_input_file, starting two instances of my_script.py to run at the same time.

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 LittleFox