[英]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.我在硬件、GPU 和 CPU 方面没有丰富的知识,所以我正在尝试创建它。 I have a server with N processor, the description for each of them is more or less the following one:
我有一台带有 N 个处理器的服务器,每个处理器的描述或多或少如下:
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.我没有作业调度程序,所以我使用 tmux 或 screen 来处理我的代码。 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?
我的问题是,我如何处理处理器并使用它们中的 3 个,或更少或更多,并运行我的 python 代码? I'm very confused about that.
我对此很困惑。
Thank you谢谢
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 eg 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.单个线程将始终只使用单个 CPU,您需要多个线程才能使用更多 CPU。 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.既然你提到
tmux
,也许 bash 的作业控制可以帮助你 - 简短的例子是my_script.py input_file & my_script.py another_input_file
,同时启动my_script.py
的两个实例运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.