keep-gpu 0.1.0.post2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. keep_gpu-0.1.0.post2/AUTHORS.rst +13 -0
  2. keep_gpu-0.1.0.post2/CONTRIBUTING.rst +137 -0
  3. keep_gpu-0.1.0.post2/HISTORY.rst +8 -0
  4. keep_gpu-0.1.0.post2/LICENSE +21 -0
  5. keep_gpu-0.1.0.post2/MANIFEST.in +11 -0
  6. keep_gpu-0.1.0.post2/PKG-INFO +62 -0
  7. keep_gpu-0.1.0.post2/README.rst +41 -0
  8. keep_gpu-0.1.0.post2/docs/Makefile +20 -0
  9. keep_gpu-0.1.0.post2/docs/authors.rst +1 -0
  10. keep_gpu-0.1.0.post2/docs/conf.py +162 -0
  11. keep_gpu-0.1.0.post2/docs/contributing.rst +1 -0
  12. keep_gpu-0.1.0.post2/docs/history.rst +1 -0
  13. keep_gpu-0.1.0.post2/docs/index.rst +20 -0
  14. keep_gpu-0.1.0.post2/docs/installation.rst +51 -0
  15. keep_gpu-0.1.0.post2/docs/make.bat +36 -0
  16. keep_gpu-0.1.0.post2/docs/readme.rst +1 -0
  17. keep_gpu-0.1.0.post2/docs/usage.rst +7 -0
  18. keep_gpu-0.1.0.post2/pyproject.toml +66 -0
  19. keep_gpu-0.1.0.post2/setup.cfg +4 -0
  20. keep_gpu-0.1.0.post2/src/keep_gpu/__init__.py +5 -0
  21. keep_gpu-0.1.0.post2/src/keep_gpu/benchmark.py +51 -0
  22. keep_gpu-0.1.0.post2/src/keep_gpu/cli.py +23 -0
  23. keep_gpu-0.1.0.post2/src/keep_gpu/keep_gpu.py +27 -0
  24. keep_gpu-0.1.0.post2/src/keep_gpu.egg-info/PKG-INFO +62 -0
  25. keep_gpu-0.1.0.post2/src/keep_gpu.egg-info/SOURCES.txt +29 -0
  26. keep_gpu-0.1.0.post2/src/keep_gpu.egg-info/dependency_links.txt +1 -0
  27. keep_gpu-0.1.0.post2/src/keep_gpu.egg-info/entry_points.txt +2 -0
  28. keep_gpu-0.1.0.post2/src/keep_gpu.egg-info/requires.txt +7 -0
  29. keep_gpu-0.1.0.post2/src/keep_gpu.egg-info/top_level.txt +1 -0
  30. keep_gpu-0.1.0.post2/tests/__init__.py +1 -0
  31. keep_gpu-0.1.0.post2/tests/test_keep_gpu.py +21 -0
@@ -0,0 +1,13 @@
1
+ =======
2
+ Credits
3
+ =======
4
+
5
+ Development Lead
6
+ ----------------
7
+
8
+ * Siyuan Wang <sywang0227@gmail.com>
9
+
10
+ Contributors
11
+ ------------
12
+
13
+ None yet. Why not be the first?
@@ -0,0 +1,137 @@
1
+ .. highlight:: shell
2
+
3
+ ============
4
+ Contributing
5
+ ============
6
+
7
+ Contributions are welcome, and they are greatly appreciated! Every little bit
8
+ helps, and credit will always be given.
9
+
10
+ You can contribute in many ways:
11
+
12
+ Types of Contributions
13
+ ----------------------
14
+
15
+ Report Bugs
16
+ ~~~~~~~~~~~
17
+
18
+ Report bugs at https://github.com/Wangmerlyn/keep_gpu/issues.
19
+
20
+ If you are reporting a bug, please include:
21
+
22
+ * Your operating system name and version.
23
+ * Any details about your local setup that might be helpful in troubleshooting.
24
+ * Detailed steps to reproduce the bug.
25
+
26
+ Fix Bugs
27
+ ~~~~~~~~
28
+
29
+ Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
30
+ wanted" is open to whoever wants to implement it.
31
+
32
+ Implement Features
33
+ ~~~~~~~~~~~~~~~~~~
34
+
35
+ Look through the GitHub issues for features. Anything tagged with "enhancement"
36
+ and "help wanted" is open to whoever wants to implement it.
37
+
38
+ Write Documentation
39
+ ~~~~~~~~~~~~~~~~~~~
40
+
41
+ Keep GPU could always use more documentation, whether as part of the
42
+ official Keep GPU docs, in docstrings, or even on the web in blog posts,
43
+ articles, and such.
44
+
45
+ Submit Feedback
46
+ ~~~~~~~~~~~~~~~
47
+
48
+ The best way to send feedback is to file an issue at https://github.com/Wangmerlyn/keep_gpu/issues.
49
+
50
+ If you are proposing a feature:
51
+
52
+ * Explain in detail how it would work.
53
+ * Keep the scope as narrow as possible, to make it easier to implement.
54
+ * Remember that this is a volunteer-driven project, and that contributions
55
+ are welcome :)
56
+
57
+ Get Started!
58
+ ------------
59
+
60
+ Ready to contribute? Here's how to set up `keep_gpu` for local development.
61
+
62
+ 1. Fork the `keep_gpu` repo on GitHub.
63
+ 2. Clone your fork locally::
64
+
65
+ $ git clone git@github.com:your_name_here/keep_gpu.git
66
+
67
+ 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
68
+
69
+ $ mkvirtualenv keep_gpu
70
+ $ cd keep_gpu/
71
+ $ python setup.py develop
72
+
73
+ 4. Create a branch for local development::
74
+
75
+ $ git checkout -b name-of-your-bugfix-or-feature
76
+
77
+ Now you can make your changes locally.
78
+
79
+ 5. When you're done making changes, check that your changes pass flake8 and the
80
+ tests, including testing other Python versions with tox::
81
+
82
+ $ make lint
83
+ $ make test
84
+ Or
85
+ $ make test-all
86
+
87
+ To get flake8 and tox, just pip install them into your virtualenv.
88
+
89
+ 6. Commit your changes and push your branch to GitHub::
90
+
91
+ $ git add .
92
+ $ git commit -m "Your detailed description of your changes."
93
+ $ git push origin name-of-your-bugfix-or-feature
94
+
95
+ 7. Submit a pull request through the GitHub website.
96
+
97
+ Pull Request Guidelines
98
+ -----------------------
99
+
100
+ Before you submit a pull request, check that it meets these guidelines:
101
+
102
+ 1. The pull request should include tests.
103
+ 2. If the pull request adds functionality, the docs should be updated. Put
104
+ your new functionality into a function with a docstring, and add the
105
+ feature to the list in README.rst.
106
+ 3. The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and for PyPy. Check
107
+ https://travis-ci.com/Wangmerlyn/keep_gpu/pull_requests
108
+ and make sure that the tests pass for all supported Python versions.
109
+
110
+ Tips
111
+ ----
112
+
113
+ To run a subset of tests::
114
+
115
+
116
+ $ python -m unittest tests.test_keep_gpu
117
+
118
+ Deploying
119
+ ---------
120
+
121
+ A reminder for the maintainers on how to deploy.
122
+ Make sure all your changes are committed (including an entry in HISTORY.rst).
123
+ Then run::
124
+
125
+ $ bump2version patch # possible: major / minor / patch
126
+ $ git push
127
+ $ git push --tags
128
+
129
+ Travis will then deploy to PyPI if tests pass.
130
+
131
+ Code of Conduct
132
+ ---------------
133
+
134
+ Please note that this project is released with a `Contributor Code of Conduct`_.
135
+ By participating in this project you agree to abide by its terms.
136
+
137
+ .. _`Contributor Code of Conduct`: CODE_OF_CONDUCT.rst
@@ -0,0 +1,8 @@
1
+ =======
2
+ History
3
+ =======
4
+
5
+ 0.1.0 (2025-05-20)
6
+ ------------------
7
+
8
+ * First release on PyPI.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Wang Siyuan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ include AUTHORS.rst
2
+ include CONTRIBUTING.rst
3
+ include HISTORY.rst
4
+ include LICENSE
5
+ include README.rst
6
+
7
+ recursive-include tests *
8
+ recursive-exclude * __pycache__
9
+ recursive-exclude * *.py[co]
10
+
11
+ recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: keep_gpu
3
+ Version: 0.1.0.post2
4
+ Summary: Keep GPU is a simple cli app that keep your gpus running
5
+ Author-email: Siyuan Wang <sywang0227@gmail.com>
6
+ Maintainer-email: Siyuan Wang <sywang0227@gmail.com>
7
+ License: MIT license
8
+ Project-URL: bugs, https://github.com/Wangmerlyn/keep_gpu/issues
9
+ Project-URL: changelog, https://github.com/Wangmerlyn/keep_gpu/blob/master/changelog.md
10
+ Project-URL: homepage, https://github.com/Wangmerlyn/keep_gpu
11
+ Description-Content-Type: text/x-rst
12
+ License-File: LICENSE
13
+ License-File: AUTHORS.rst
14
+ Requires-Dist: typer
15
+ Provides-Extra: dev
16
+ Requires-Dist: coverage; extra == "dev"
17
+ Requires-Dist: mypy; extra == "dev"
18
+ Requires-Dist: pytest; extra == "dev"
19
+ Requires-Dist: ruff; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ ========
23
+ Keep GPU
24
+ ========
25
+
26
+
27
+ .. image:: https://img.shields.io/pypi/v/keep_gpu.svg
28
+ :target: https://pypi.python.org/pypi/keep_gpu
29
+
30
+ .. image:: https://img.shields.io/travis/Wangmerlyn/KeepGPU.svg
31
+ :target: https://travis-ci.com/Wangmerlyn/KeepGPU
32
+
33
+ .. image:: https://readthedocs.org/projects/keep-gpu/badge/?version=latest
34
+ :target: https://keep-gpu.readthedocs.io/en/latest/?version=latest
35
+ :alt: Documentation Status
36
+
37
+
38
+ .. image:: https://pyup.io/repos/github/Wangmerlyn/keep_gpu/shield.svg
39
+ :target: https://pyup.io/repos/github/Wangmerlyn/keep_gpu/
40
+ :alt: Updates
41
+
42
+
43
+
44
+ Keep GPU is a simple cli app that keep your gpus running
45
+
46
+
47
+ * Free software: MIT license
48
+ * Documentation: https://keep-gpu.readthedocs.io.
49
+
50
+
51
+ Features
52
+ --------
53
+
54
+ * TODO
55
+
56
+ Credits
57
+ -------
58
+
59
+ This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
60
+
61
+ .. _Cookiecutter: https://github.com/audreyr/cookiecutter
62
+ .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
@@ -0,0 +1,41 @@
1
+ ========
2
+ Keep GPU
3
+ ========
4
+
5
+
6
+ .. image:: https://img.shields.io/pypi/v/keep_gpu.svg
7
+ :target: https://pypi.python.org/pypi/keep_gpu
8
+
9
+ .. image:: https://img.shields.io/travis/Wangmerlyn/KeepGPU.svg
10
+ :target: https://travis-ci.com/Wangmerlyn/KeepGPU
11
+
12
+ .. image:: https://readthedocs.org/projects/keep-gpu/badge/?version=latest
13
+ :target: https://keep-gpu.readthedocs.io/en/latest/?version=latest
14
+ :alt: Documentation Status
15
+
16
+
17
+ .. image:: https://pyup.io/repos/github/Wangmerlyn/keep_gpu/shield.svg
18
+ :target: https://pyup.io/repos/github/Wangmerlyn/keep_gpu/
19
+ :alt: Updates
20
+
21
+
22
+
23
+ Keep GPU is a simple cli app that keep your gpus running
24
+
25
+
26
+ * Free software: MIT license
27
+ * Documentation: https://keep-gpu.readthedocs.io.
28
+
29
+
30
+ Features
31
+ --------
32
+
33
+ * TODO
34
+
35
+ Credits
36
+ -------
37
+
38
+ This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
39
+
40
+ .. _Cookiecutter: https://github.com/audreyr/cookiecutter
41
+ .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line.
5
+ SPHINXOPTS =
6
+ SPHINXBUILD = python -msphinx
7
+ SPHINXPROJ = keep_gpu
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1 @@
1
+ .. include:: ../AUTHORS.rst
@@ -0,0 +1,162 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # keep_gpu documentation build configuration file, created by
4
+ # sphinx-quickstart on Fri Jun 9 13:47:02 2017.
5
+ #
6
+ # This file is execfile()d with the current directory set to its
7
+ # containing dir.
8
+ #
9
+ # Note that not all possible configuration values are present in this
10
+ # autogenerated file.
11
+ #
12
+ # All configuration values have a default; values that are commented out
13
+ # serve to show the default.
14
+
15
+ # If extensions (or modules to document with autodoc) are in another
16
+ # directory, add these directories to sys.path here. If the directory is
17
+ # relative to the documentation root, use os.path.abspath to make it
18
+ # absolute, like shown here.
19
+ #
20
+ import os
21
+ import sys
22
+ sys.path.insert(0, os.path.abspath('..'))
23
+
24
+ import keep_gpu
25
+
26
+ # -- General configuration ---------------------------------------------
27
+
28
+ # If your documentation needs a minimal Sphinx version, state it here.
29
+ #
30
+ # needs_sphinx = '1.0'
31
+
32
+ # Add any Sphinx extension module names here, as strings. They can be
33
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
34
+ extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
35
+
36
+ # Add any paths that contain templates here, relative to this directory.
37
+ templates_path = ['_templates']
38
+
39
+ # The suffix(es) of source filenames.
40
+ # You can specify multiple suffix as a list of string:
41
+ #
42
+ # source_suffix = ['.rst', '.md']
43
+ source_suffix = '.rst'
44
+
45
+ # The master toctree document.
46
+ master_doc = 'index'
47
+
48
+ # General information about the project.
49
+ project = 'Keep GPU'
50
+ copyright = "2025, Siyuan Wang"
51
+ author = "Siyuan Wang"
52
+
53
+ # The version info for the project you're documenting, acts as replacement
54
+ # for |version| and |release|, also used in various other places throughout
55
+ # the built documents.
56
+ #
57
+ # The short X.Y version.
58
+ version = keep_gpu.__version__
59
+ # The full version, including alpha/beta/rc tags.
60
+ release = keep_gpu.__version__
61
+
62
+ # The language for content autogenerated by Sphinx. Refer to documentation
63
+ # for a list of supported languages.
64
+ #
65
+ # This is also used if you do content translation via gettext catalogs.
66
+ # Usually you set "language" from the command line for these cases.
67
+ language = None
68
+
69
+ # List of patterns, relative to source directory, that match files and
70
+ # directories to ignore when looking for source files.
71
+ # This patterns also effect to html_static_path and html_extra_path
72
+ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
73
+
74
+ # The name of the Pygments (syntax highlighting) style to use.
75
+ pygments_style = 'sphinx'
76
+
77
+ # If true, `todo` and `todoList` produce output, else they produce nothing.
78
+ todo_include_todos = False
79
+
80
+
81
+ # -- Options for HTML output -------------------------------------------
82
+
83
+ # The theme to use for HTML and HTML Help pages. See the documentation for
84
+ # a list of builtin themes.
85
+ #
86
+ html_theme = 'alabaster'
87
+
88
+ # Theme options are theme-specific and customize the look and feel of a
89
+ # theme further. For a list of options available for each theme, see the
90
+ # documentation.
91
+ #
92
+ # html_theme_options = {}
93
+
94
+ # Add any paths that contain custom static files (such as style sheets) here,
95
+ # relative to this directory. They are copied after the builtin static files,
96
+ # so a file named "default.css" will overwrite the builtin "default.css".
97
+ html_static_path = ['_static']
98
+
99
+
100
+ # -- Options for HTMLHelp output ---------------------------------------
101
+
102
+ # Output file base name for HTML help builder.
103
+ htmlhelp_basename = 'keep_gpudoc'
104
+
105
+
106
+ # -- Options for LaTeX output ------------------------------------------
107
+
108
+ latex_elements = {
109
+ # The paper size ('letterpaper' or 'a4paper').
110
+ #
111
+ # 'papersize': 'letterpaper',
112
+
113
+ # The font size ('10pt', '11pt' or '12pt').
114
+ #
115
+ # 'pointsize': '10pt',
116
+
117
+ # Additional stuff for the LaTeX preamble.
118
+ #
119
+ # 'preamble': '',
120
+
121
+ # Latex figure (float) alignment
122
+ #
123
+ # 'figure_align': 'htbp',
124
+ }
125
+
126
+ # Grouping the document tree into LaTeX files. List of tuples
127
+ # (source start file, target name, title, author, documentclass
128
+ # [howto, manual, or own class]).
129
+ latex_documents = [
130
+ (master_doc, 'keep_gpu.tex',
131
+ 'Keep GPU Documentation',
132
+ 'Siyuan Wang', 'manual'),
133
+ ]
134
+
135
+
136
+ # -- Options for manual page output ------------------------------------
137
+
138
+ # One entry per manual page. List of tuples
139
+ # (source start file, name, description, authors, manual section).
140
+ man_pages = [
141
+ (master_doc, 'keep_gpu',
142
+ 'Keep GPU Documentation',
143
+ [author], 1)
144
+ ]
145
+
146
+
147
+ # -- Options for Texinfo output ----------------------------------------
148
+
149
+ # Grouping the document tree into Texinfo files. List of tuples
150
+ # (source start file, target name, title, author,
151
+ # dir menu entry, description, category)
152
+ texinfo_documents = [
153
+ (master_doc, 'keep_gpu',
154
+ 'Keep GPU Documentation',
155
+ author,
156
+ 'keep_gpu',
157
+ 'One line description of project.',
158
+ 'Miscellaneous'),
159
+ ]
160
+
161
+
162
+
@@ -0,0 +1 @@
1
+ .. include:: ../CONTRIBUTING.rst
@@ -0,0 +1 @@
1
+ .. include:: ../HISTORY.rst
@@ -0,0 +1,20 @@
1
+ Welcome to Keep GPU's documentation!
2
+ ======================================
3
+
4
+ .. toctree::
5
+ :maxdepth: 2
6
+ :caption: Contents:
7
+
8
+ readme
9
+ installation
10
+ usage
11
+ modules
12
+ contributing
13
+ authors
14
+ history
15
+
16
+ Indices and tables
17
+ ==================
18
+ * :ref:`genindex`
19
+ * :ref:`modindex`
20
+ * :ref:`search`
@@ -0,0 +1,51 @@
1
+ .. highlight:: shell
2
+
3
+ ============
4
+ Installation
5
+ ============
6
+
7
+
8
+ Stable release
9
+ --------------
10
+
11
+ To install Keep GPU, run this command in your terminal:
12
+
13
+ .. code-block:: console
14
+
15
+ $ pip install keep_gpu
16
+
17
+ This is the preferred method to install Keep GPU, as it will always install the most recent stable release.
18
+
19
+ If you don't have `pip`_ installed, this `Python installation guide`_ can guide
20
+ you through the process.
21
+
22
+ .. _pip: https://pip.pypa.io
23
+ .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/
24
+
25
+
26
+ From sources
27
+ ------------
28
+
29
+ The sources for Keep GPU can be downloaded from the `Github repo`_.
30
+
31
+ You can either clone the public repository:
32
+
33
+ .. code-block:: console
34
+
35
+ $ git clone git://github.com/Wangmerlyn/keep_gpu
36
+
37
+ Or download the `tarball`_:
38
+
39
+ .. code-block:: console
40
+
41
+ $ curl -OJL https://github.com/Wangmerlyn/keep_gpu/tarball/master
42
+
43
+ Once you have a copy of the source, you can install it with:
44
+
45
+ .. code-block:: console
46
+
47
+ $ python setup.py install
48
+
49
+
50
+ .. _Github repo: https://github.com/Wangmerlyn/keep_gpu
51
+ .. _tarball: https://github.com/Wangmerlyn/keep_gpu/tarball/master
@@ -0,0 +1,36 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=python -msphinx
9
+ )
10
+ set SOURCEDIR=.
11
+ set BUILDDIR=_build
12
+ set SPHINXPROJ=keep_gpu
13
+
14
+ if "%1" == "" goto help
15
+
16
+ %SPHINXBUILD% >NUL 2>NUL
17
+ if errorlevel 9009 (
18
+ echo.
19
+ echo.The Sphinx module was not found. Make sure you have Sphinx installed,
20
+ echo.then set the SPHINXBUILD environment variable to point to the full
21
+ echo.path of the 'sphinx-build' executable. Alternatively you may add the
22
+ echo.Sphinx directory to PATH.
23
+ echo.
24
+ echo.If you don't have Sphinx installed, grab it from
25
+ echo.http://sphinx-doc.org/
26
+ exit /b 1
27
+ )
28
+
29
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30
+ goto end
31
+
32
+ :help
33
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
34
+
35
+ :end
36
+ popd
@@ -0,0 +1 @@
1
+ .. include:: ../README.rst
@@ -0,0 +1,7 @@
1
+ =====
2
+ Usage
3
+ =====
4
+
5
+ To use Keep GPU in a project::
6
+
7
+ import keep_gpu
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "keep_gpu"
7
+ version = "0.1.0.post2"
8
+ description = "Keep GPU is a simple cli app that keep your gpus running"
9
+ readme = "README.rst"
10
+ authors = [
11
+ {name = "Siyuan Wang", email = "sywang0227@gmail.com"}
12
+ ]
13
+ maintainers = [
14
+ {name = "Siyuan Wang", email = "sywang0227@gmail.com"}
15
+ ]
16
+ classifiers = [
17
+
18
+ ]
19
+ license = {text = "MIT license"}
20
+ dependencies = [
21
+ "typer"
22
+ ]
23
+
24
+ [project.scripts]
25
+ keep-gpu = "keep_gpu.cli:main"
26
+
27
+ [project.optional-dependencies]
28
+ dev = [
29
+ "coverage", # testing
30
+ "mypy", # linting
31
+ "pytest", # testing
32
+ "ruff" # linting
33
+ ]
34
+
35
+ [project.urls]
36
+
37
+ bugs = "https://github.com/Wangmerlyn/keep_gpu/issues"
38
+ changelog = "https://github.com/Wangmerlyn/keep_gpu/blob/master/changelog.md"
39
+ homepage = "https://github.com/Wangmerlyn/keep_gpu"
40
+
41
+ [tool.setuptools]
42
+ package-dir = {"" = "src"}
43
+
44
+ [tool.setuptools.package-data]
45
+ "*" = ["*.*"]
46
+
47
+
48
+
49
+
50
+ # Mypy
51
+ # ----
52
+
53
+ [tool.mypy]
54
+ files = "."
55
+
56
+ # Use strict defaults
57
+ strict = true
58
+ warn_unreachable = true
59
+ warn_no_return = true
60
+
61
+ [[tool.mypy.overrides]]
62
+ # Don't require test functions to include types
63
+ module = "tests.*"
64
+ allow_untyped_defs = true
65
+ disable_error_code = "attr-defined"
66
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ """Top-level package for Keep GPU."""
2
+
3
+ __author__ = """Siyuan Wang"""
4
+ __email__ = 'sywang0227@gmail.com'
5
+ __version__ = '0.1.0.post2'
@@ -0,0 +1,51 @@
1
+ import torch
2
+ import time
3
+ import subprocess
4
+ import re
5
+ import random
6
+
7
+ def get_gpu_util(rank):
8
+ cmds = ['nvidia-smi', '-i', str(rank)]
9
+ proc = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
10
+ stdout, stderr = proc.communicate()
11
+ outputs = stdout.decode('utf-8').split('\n')
12
+
13
+ util = 0
14
+ for output in outputs[::-1]:
15
+ if 'Default' in output:
16
+ util = int(re.findall(r'\d+', output)[-1])
17
+ break
18
+ else:
19
+ print(f"rank {rank}: couldn't match any, check GPU status!")
20
+ return util
21
+
22
+ def keep(rank, args):
23
+ torch.cuda.set_device(rank)
24
+ print(f'benchmarking {args.gpus} gpus...')
25
+ while True:
26
+ n = random.randint(5, 9)
27
+ a = torch.rand((8192 * n, 8192)).cuda()
28
+ b = torch.rand((8192 * n, 8192)).cuda()
29
+
30
+ tic = time.time()
31
+ for _ in range(5000):
32
+ c = a * b
33
+ torch.cuda.synchronize()
34
+ toc = time.time()
35
+ if rank == 0:
36
+ print('benchmark 5K matmul: time span: {}ms'.format((toc - tic) * 1000 / 5000))
37
+
38
+ time.sleep(args.interval)
39
+ while get_gpu_util(rank) > 10:
40
+ print(f'rank {rank}: GPU busy, sleeping...')
41
+ time.sleep(args.interval)
42
+ print(f'rank {rank} resumes')
43
+
44
+ def run_benchmark(gpus=1, interval=100):
45
+ class Args:
46
+ def __init__(self, gpus, interval):
47
+ self.gpus = gpus
48
+ self.interval = interval
49
+
50
+ args = Args(gpus, interval)
51
+ torch.multiprocessing.spawn(keep, args=(args,), nprocs=gpus, join=True)
@@ -0,0 +1,23 @@
1
+ """Console script for keep_gpu."""
2
+ import keep_gpu
3
+ from .keep_gpu import run
4
+
5
+ import typer
6
+ from rich.console import Console
7
+
8
+ app = typer.Typer()
9
+ console = Console()
10
+
11
+
12
+ @app.command()
13
+ def main():
14
+ """Console script for keep_gpu."""
15
+ console.print("Replace this message by putting your code into "
16
+ "keep_gpu.cli.main")
17
+ console.print("See Typer documentation at https://typer.tiangolo.com/")
18
+ run()
19
+
20
+
21
+
22
+ if __name__ == "__main__":
23
+ app()
@@ -0,0 +1,27 @@
1
+ import subprocess
2
+ import time
3
+ import os
4
+ import torch
5
+
6
+ from .benchmark import run_benchmark
7
+
8
+ def check_gpu_usage():
9
+ result = subprocess.run(['nvidia-smi', '--query-gpu=utilization.gpu', '--format=csv,noheader'], capture_output=True, text=True)
10
+ gpu_usages = [int(line.split()[0]) for line in result.stdout.strip().split('\n')]
11
+ return any(usage > 0 for usage in gpu_usages)
12
+
13
+ def run():
14
+ idle_count = 0
15
+ gpu_count = torch.cuda.device_count()
16
+ print(f'GPU count: {gpu_count}')
17
+ while True:
18
+ if not check_gpu_usage():
19
+ idle_count += 1
20
+ else:
21
+ idle_count = 0
22
+
23
+ if idle_count >= 1:
24
+ run_benchmark(gpu_count)
25
+ idle_count = 0
26
+
27
+ time.sleep(300)
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: keep_gpu
3
+ Version: 0.1.0.post2
4
+ Summary: Keep GPU is a simple cli app that keep your gpus running
5
+ Author-email: Siyuan Wang <sywang0227@gmail.com>
6
+ Maintainer-email: Siyuan Wang <sywang0227@gmail.com>
7
+ License: MIT license
8
+ Project-URL: bugs, https://github.com/Wangmerlyn/keep_gpu/issues
9
+ Project-URL: changelog, https://github.com/Wangmerlyn/keep_gpu/blob/master/changelog.md
10
+ Project-URL: homepage, https://github.com/Wangmerlyn/keep_gpu
11
+ Description-Content-Type: text/x-rst
12
+ License-File: LICENSE
13
+ License-File: AUTHORS.rst
14
+ Requires-Dist: typer
15
+ Provides-Extra: dev
16
+ Requires-Dist: coverage; extra == "dev"
17
+ Requires-Dist: mypy; extra == "dev"
18
+ Requires-Dist: pytest; extra == "dev"
19
+ Requires-Dist: ruff; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ ========
23
+ Keep GPU
24
+ ========
25
+
26
+
27
+ .. image:: https://img.shields.io/pypi/v/keep_gpu.svg
28
+ :target: https://pypi.python.org/pypi/keep_gpu
29
+
30
+ .. image:: https://img.shields.io/travis/Wangmerlyn/KeepGPU.svg
31
+ :target: https://travis-ci.com/Wangmerlyn/KeepGPU
32
+
33
+ .. image:: https://readthedocs.org/projects/keep-gpu/badge/?version=latest
34
+ :target: https://keep-gpu.readthedocs.io/en/latest/?version=latest
35
+ :alt: Documentation Status
36
+
37
+
38
+ .. image:: https://pyup.io/repos/github/Wangmerlyn/keep_gpu/shield.svg
39
+ :target: https://pyup.io/repos/github/Wangmerlyn/keep_gpu/
40
+ :alt: Updates
41
+
42
+
43
+
44
+ Keep GPU is a simple cli app that keep your gpus running
45
+
46
+
47
+ * Free software: MIT license
48
+ * Documentation: https://keep-gpu.readthedocs.io.
49
+
50
+
51
+ Features
52
+ --------
53
+
54
+ * TODO
55
+
56
+ Credits
57
+ -------
58
+
59
+ This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
60
+
61
+ .. _Cookiecutter: https://github.com/audreyr/cookiecutter
62
+ .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
@@ -0,0 +1,29 @@
1
+ AUTHORS.rst
2
+ CONTRIBUTING.rst
3
+ HISTORY.rst
4
+ LICENSE
5
+ MANIFEST.in
6
+ README.rst
7
+ pyproject.toml
8
+ docs/Makefile
9
+ docs/authors.rst
10
+ docs/conf.py
11
+ docs/contributing.rst
12
+ docs/history.rst
13
+ docs/index.rst
14
+ docs/installation.rst
15
+ docs/make.bat
16
+ docs/readme.rst
17
+ docs/usage.rst
18
+ src/keep_gpu/__init__.py
19
+ src/keep_gpu/benchmark.py
20
+ src/keep_gpu/cli.py
21
+ src/keep_gpu/keep_gpu.py
22
+ src/keep_gpu.egg-info/PKG-INFO
23
+ src/keep_gpu.egg-info/SOURCES.txt
24
+ src/keep_gpu.egg-info/dependency_links.txt
25
+ src/keep_gpu.egg-info/entry_points.txt
26
+ src/keep_gpu.egg-info/requires.txt
27
+ src/keep_gpu.egg-info/top_level.txt
28
+ tests/__init__.py
29
+ tests/test_keep_gpu.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ keep-gpu = keep_gpu.cli:main
@@ -0,0 +1,7 @@
1
+ typer
2
+
3
+ [dev]
4
+ coverage
5
+ mypy
6
+ pytest
7
+ ruff
@@ -0,0 +1 @@
1
+ """Unit test package for keep_gpu."""
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env python
2
+
3
+ """Tests for `keep_gpu` package."""
4
+
5
+
6
+ import unittest
7
+
8
+ from keep_gpu import keep_gpu
9
+
10
+
11
+ class TestKeep_gpu(unittest.TestCase):
12
+ """Tests for `keep_gpu` package."""
13
+
14
+ def setUp(self):
15
+ """Set up test fixtures, if any."""
16
+
17
+ def tearDown(self):
18
+ """Tear down test fixtures, if any."""
19
+
20
+ def test_000_something(self):
21
+ """Test something."""