---
title: 绑定训练进程到指定CPU
description: "多P训练场景，为了使Host CPU调度均匀，从而进一步提高训练性能，用户可以参考如下步骤将训练进程绑定到指定的CPU上，用于平均分配Host CPU调度数，下面以8P举例说明："
url: https://www.hiascend.com/document/detail/zh/TensorFlowCommercial/latest/migration/tfmigr1/tfmigr1_000112.html
sourcePath: /source/zh/TensorFlowCommercial/900/migration/tfmigr1/tfmigr1_000112.html
indexId: 8ffa368b3e786d4487cd92c87b3d6f991673bf5f6ac198f6b3295825cc369b4f73
---
# 绑定训练进程到指定CPU

多P训练场景，为了使Host CPU调度均匀，从而进一步提高训练性能，用户可以参考如下步骤将训练进程绑定到指定的CPU上，用于平均分配Host CPU调度数，下面以8P举例说明：

1. 查询HOST CPU个数，例如：Total CPU =96。
2. 计算每个训练进程分配的Host CPU调度数n。
  n = Total CPU / 8 = 12。

3. 修改训练进程启动脚本，在启动训练脚本前，使用“taskset -c ”绑定进程到指定的Host CPU。例如：
  Device0：

```
taskset -c 0-11 python3 /home/test/xxx.py /
```


  Device7：

```
taskset -c 84-95 python3 /home/test/xxx.py /
```
