{ "info": { "author": "Thomas Moreau", "author_email": "thomas.moreau.2010@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Thread-pool Controls [![Build Status](https://dev.azure.com/joblib/threadpoolctl/_apis/build/status/joblib.threadpoolctl?branchName=master)](https://dev.azure.com/joblib/threadpoolctl/_build/latest?definitionId=1&branchName=master) [![codecov](https://codecov.io/gh/joblib/threadpoolctl/branch/master/graph/badge.svg)](https://codecov.io/gh/joblib/threadpoolctl)\n\nPython helpers to limit the number of threads used in the\nthreadpool-backed of common native libraries used for scientific\ncomputing and data science (e.g. BLAS and OpenMP).\n\nFine control of the underlying thread-pool size can be useful in\nworkloads that involve nested parallelism so as to mitigate\noversubscription issues.\n\n## Installation\n\n- For users, install the last published version from PyPI:\n\n ```bash\n pip install threadpoolctl\n ```\n\n- For contributors, install from the source repository in developer\n mode:\n\n ```bash\n pip install -r dev-requirements.txt\n flit install --symlink\n ```\n\n then you run the tests with pytest:\n\n ```bash\n pytest\n ```\n\n## Usage\n\n### Runtime Introspection\n\nIntrospect the current state of the threadpool-enabled runtime libraries\nthat are loaded when importing Python packages:\n\n```python\n>>> from threadpoolctl import threadpool_info\n>>> from pprint import pprint\n>>> pprint(threadpool_info())\n[]\n\n>>> import numpy\n>>> pprint(threadpool_info())\n[{'filepath': '/opt/venvs/py37/lib/python3.7/site-packages/numpy/.libs/libopenblasp-r0-382c8f3a.3.5.dev.so',\n 'internal_api': 'openblas',\n 'num_threads': 4,\n 'prefix': 'libopenblas',\n 'user_api': 'blas',\n 'version': '0.3.5.dev'}]\n\n>>> import xgboost\n>>> pprint(threadpool_info())\n[{'filepath': '/opt/venvs/py37/lib/python3.7/site-packages/numpy/.libs/libopenblasp-r0-382c8f3a.3.5.dev.so',\n 'internal_api': 'openblas',\n 'num_threads': 4,\n 'prefix': 'libopenblas',\n 'user_api': 'blas',\n 'version': '0.3.5.dev'},\n {'filepath': '/opt/venvs/py37/lib/python3.7/site-packages/scipy/.libs/libopenblasp-r0-8dca6697.3.0.dev.so',\n 'internal_api': 'openblas',\n 'num_threads': 4,\n 'prefix': 'libopenblas',\n 'user_api': 'blas',\n 'version': None},\n {'filepath': '/usr/lib/x86_64-linux-gnu/libgomp.so.1',\n 'internal_api': 'openmp',\n 'num_threads': 4,\n 'prefix': 'libgomp',\n 'user_api': 'openmp',\n 'version': None}]\n```\n\n### Set the maximum size of thread-pools\n\nControl the number of threads used by the underlying runtime libraries\nin specific sections of your Python program:\n\n```python\nfrom threadpoolctl import threadpool_limits\nimport numpy as np\n\n\nwith threadpool_limits(limits=1, user_api='blas'):\n # In this block, calls to blas implementation (like openblas or MKL)\n # will be limited to use only one thread. They can thus be used jointly\n # with thread-parallelism.\n a = np.random.randn(1000, 1000)\n a_squared = a @ a\n```\n\n### Known limitation\n\n`threadpool_limits` does not act as expected in nested parallel loops\nmanaged by distinct OpenMP runtime implementations (for instance libgomp\nfrom GCC and libomp from clang/llvm or libiomp from ICC).\n\nSee the `test_openmp_nesting()` function in `tests/test_threadpoolctl.py`\nfor an example.\n\n## Maintainers\n\nTo make a release:\n\nBump the version number (`__version__`) in `threadpoolctl.py`.\n\nBuild the distribution archives:\n\n```bash\npip install flit\nflit build\n```\n\nCheck the contents of `dist/`.\n\nIf everything is fine, make a commit for the release, tag it, push the\ntag to github and then:\n\n```bash\nflit publish\n```\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/joblib/threadpoolctl", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "threadpoolctl", "package_url": "https://pypi.org/project/threadpoolctl/", "platform": "", "project_url": "https://pypi.org/project/threadpoolctl/", "project_urls": { "Homepage": "https://github.com/joblib/threadpoolctl" }, "release_url": "https://pypi.org/project/threadpoolctl/1.1.0/", "requires_dist": null, "requires_python": ">=3.5", "summary": "threadpoolctl", "version": "1.1.0" }, "last_serial": 5821217, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "0699b4185c5ffc61b5b72a05a7aa70f6", "sha256": "000a0d6a4e83e0f046a9994ea103932bab20a51108e4d79fca3ad35b643d5dd2" }, "downloads": -1, "filename": "threadpoolctl-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "0699b4185c5ffc61b5b72a05a7aa70f6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 24350, "upload_time": "2019-06-03T13:48:32", "url": "https://files.pythonhosted.org/packages/05/1e/b36153c14f32adf6431ef66adf0954c7b907a4fc1eb845f34fa135d9674a/threadpoolctl-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "247092b13ab8ae0f4f7c60e2a974b464", "sha256": "e0d65c8883f8074607624d9767539ea9bb763ea8d7ce2b403ead10eab01871bc" }, "downloads": -1, "filename": "threadpoolctl-1.0.0.tar.gz", "has_sig": false, "md5_digest": "247092b13ab8ae0f4f7c60e2a974b464", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 17520, "upload_time": "2019-06-03T13:48:34", "url": "https://files.pythonhosted.org/packages/16/66/9c8b241425ddce72873e356d593ecced09ccf5c57148173a055b5be98c4b/threadpoolctl-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "290b79daaeb1832d73263450eb2479a1", "sha256": "fd69f43f4d6e8d861b4e1715a9c909cb01973220b21493b6bb261a1d1172d3d8" }, "downloads": -1, "filename": "threadpoolctl-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "290b79daaeb1832d73263450eb2479a1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 26257, "upload_time": "2019-09-12T15:46:44", "url": "https://files.pythonhosted.org/packages/bd/09/88c9d47193bffd0925e4495f8074e424d7d93de5dbd97d893bc429175af7/threadpoolctl-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2744693260320318c7fe7d90f98266bf", "sha256": "86f330c5ead7fd2d2143e76c4a4cc032d5a2f9cd4c4857fa06847cae2211ab82" }, "downloads": -1, "filename": "threadpoolctl-1.1.0.tar.gz", "has_sig": false, "md5_digest": "2744693260320318c7fe7d90f98266bf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 19886, "upload_time": "2019-09-12T15:46:45", "url": "https://files.pythonhosted.org/packages/d3/e3/20510e8a060fe36545752a54375d85f77232f7094a7d85824c24cffe7e0a/threadpoolctl-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "290b79daaeb1832d73263450eb2479a1", "sha256": "fd69f43f4d6e8d861b4e1715a9c909cb01973220b21493b6bb261a1d1172d3d8" }, "downloads": -1, "filename": "threadpoolctl-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "290b79daaeb1832d73263450eb2479a1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 26257, "upload_time": "2019-09-12T15:46:44", "url": "https://files.pythonhosted.org/packages/bd/09/88c9d47193bffd0925e4495f8074e424d7d93de5dbd97d893bc429175af7/threadpoolctl-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2744693260320318c7fe7d90f98266bf", "sha256": "86f330c5ead7fd2d2143e76c4a4cc032d5a2f9cd4c4857fa06847cae2211ab82" }, "downloads": -1, "filename": "threadpoolctl-1.1.0.tar.gz", "has_sig": false, "md5_digest": "2744693260320318c7fe7d90f98266bf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 19886, "upload_time": "2019-09-12T15:46:45", "url": "https://files.pythonhosted.org/packages/d3/e3/20510e8a060fe36545752a54375d85f77232f7094a7d85824c24cffe7e0a/threadpoolctl-1.1.0.tar.gz" } ] }