{"id":28988727,"url":"https://github.com/eidoslab/swarm-cpupin","last_synced_at":"2025-08-08T20:18:08.835Z","repository":{"id":82117000,"uuid":"480062082","full_name":"EIDOSLAB/swarm-cpupin","owner":"EIDOSLAB","description":"Automatic CPU pinning for docker swarm based GPU HPC cluster","archived":false,"fork":false,"pushed_at":"2022-07-01T15:44:31.000Z","size":17,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-24T22:06:42.035Z","etag":null,"topics":["cpu","cpu-scheduling","docker","pinning","swarm"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EIDOSLAB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-04-10T15:41:22.000Z","updated_at":"2022-05-02T11:17:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"1164f9b8-3ff3-4ab2-a7dc-a00d6c7ec51d","html_url":"https://github.com/EIDOSLAB/swarm-cpupin","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/EIDOSLAB/swarm-cpupin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EIDOSLAB%2Fswarm-cpupin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EIDOSLAB%2Fswarm-cpupin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EIDOSLAB%2Fswarm-cpupin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EIDOSLAB%2Fswarm-cpupin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EIDOSLAB","download_url":"https://codeload.github.com/EIDOSLAB/swarm-cpupin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EIDOSLAB%2Fswarm-cpupin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269482592,"owners_count":24424403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpu","cpu-scheduling","docker","pinning","swarm"],"created_at":"2025-06-24T22:06:40.135Z","updated_at":"2025-08-08T20:18:08.826Z","avatar_url":"https://github.com/EIDOSLAB.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swarm CPU pinner\n\n## Automatic CPU pinning for Docker Swarm GPU HPC cluster \n\n- Docker swarm does not support the ```--cpuset-cpus``` argument.\n- This package provides a way to automatically assign a predefined set of cores to a swarm service, based on the GPU(s) it is using.\n- It runs as global service on a swarm cluster (replicated on each node), intercepts the creation of new containers, and update their cpu affinity settings at runtime\n\n**PoC use-case:** Multiple nodes with each:\n- 8 gpus\n- 96 cpu cores\n\nPinning is the best way to obtain maximum performance, and avoid multiple containers contesting the same cores.\n\nIn the setup above, 96/8 = 12 cores can be dedicated to each single GPU:\n\n| GPU id| Cores |\n|-------|-------|\n| 0 | 0-11 |\n| 1 | 12-23 |\n| 2 | 24-35 | \n| 3 | 36-47 |\n| 4 | 48-59 |\n| 5 | 60-71 |\n| 6 | 72-83 |\n| 7 | 84-95 | \n\nThis package works by looking for the DOCKER_RESOURCE_GPU in the container env vars, and matching the gpu uuid with the contents of /etc/docker/daemon.json (for details: https://gist.github.com/tomlankhorst/33da3c4b9edbde5c83fc1244f010815c)\n\n### Example usage\n\nOn the swarm manager run (first, build the image with the provided Dockerfile):\n\n```bash\ndocker service create \\\n    --restart-condition=on-failure \\\n    --mode global \\\n    --mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock \\ \n    --mount type=bind,source=/etc/docker/daemon.json,destination=/etc/docker/daemon.json \\\n    --hostname {{.Service.Name}}-{{.Node.Hostname}} \\\n    --name swarm-cpuin \\\n    ghcr.io/eidoslab/swarm-cpupin:1.0.3\n```\n\nNow, when you deploy swarm services with \n\n```\ndocker service create ... \\\n    --generic-resource gpu=1 \\\n    ...\n```\nthe spawned container(s) will be automatically pinned to the corresponding cpu cores.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feidoslab%2Fswarm-cpupin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feidoslab%2Fswarm-cpupin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feidoslab%2Fswarm-cpupin/lists"}