How to change CPU Affinity in nvidia-smi topo

nvidia-smi topo -m shows CPU affinity.

How to get cpu affinity information by nvidia-smi?
also Is there any way to change the CPU affinity.


CPU affinity refers to the CPU (of a 2 or 4 socket system) that is “closest” to the GPU. It means which CPU socket is the GPU connected to.

So you can’t change CPU affinity unless you open up the server and move things around.

nvidia-smi topo -m 

is the command to display the topology info, which includes CPU affinity

1 Like

Thank you for your description.

In my case, CPU affinity is changed for SNC(Sub-NUMA Cluster) enable or not. But regrettably, I cannot access the machine at this moment. So I close this issue.

I think I can probably improve my previous statement.

When referring to “CPU” meaning a logical CPU core identifier (such as what is used in nvidia-smi topo -m), then various system BIOS configuration parameters can have an effect on CPU affinity. The system BIOS has some control over the logical-to-physical mapping of logical CPU cores to physical CPU cores. Even apart from the parameter you mention, for example, some system BIOSes offer different numbering options, for example, in a 2 socket server, some options number logical cores such that all odd numbered cores belong to one socket (i.e. are mapped to physical cores on that socket) and even numbered cores belong to the other. Another option sometimes present is to group cores, so that logical cores 0-11 for example belong to one socket, and 12-23 belong to the other.

When taking this view, then yes, you can change the CPU affinity relationship for a GPU. The thing you cannot change (in my experience) is the relationship between GPU and physical CPU core affinity. But if you “renumber” those physical cores, then you can change the affinity when viewed in the “logical core space”.

For some time/many CPUs, CPUs had a single NUMA node per socket. I don’t wish to write a description of what a NUMA node is, please google for understanding on NUMA. Lately, I have noticed various CPUs that have multiple NUMA nodes per socket. If you make a system BIOS change or other similar system configuration change that impacts NUMA organization, you may very well alter the CPU affinity as well.

CUDA and/or NVIDIA tools don’t provide any way to change CPU affinity. You should refer to your own system documentation for understanding of the logical-to-physical relationships that are controllable with your system.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.