pytorchures


Namepytorchures JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
SummaryMeasure execution time of every layer in your pytorch model.
upload_time2024-09-26 21:00:06
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseCopyright (c) 2024 Cezary Bloch Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords pytorch performance layers profiling
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pytorch profiler
Pytorchures is a simple model profiler intended for any pytorch model. 
It measures execution time of model layers individually. Every layer of a model is wrapped with timing class which measures latency when called.

TLDR;

Install
```
git clone https://github.com/cezbloch/pytorchures.git

pip install -e .
```

Run
```
from pytorchures.timing import wrap_model_layers

wrap_model_layers(model)

model(inputs)
```

Execution time of every layer is stored in ```profiling.log``` file.

# Setup

This repo was developed under WSL 2 running Ubuntu 20.04 LTS. The editor of choice is VS Code. 

## Install python 

The code was tested for Python 3.11 and 3.10, if you want to run Python 3.10 or other future version please subsitute the python version in the command below.

In case of running new WSL below are required packages and commands.

```sudo apt-get update```

```sudo apt-get install python3.11```

```sudo apt-get install python3.11-venv```

Install for PIL image.show() to work on WSL
```sudo apt install imagemagick```

## Install relevant VS Code extentions.

If you choose to use the recommended VS Code as editor please install the extensions from  ```extensions.json```.

## Create virtual environment

Create venv 

```python3.11 -m venv .venv```

Install requirements.txt

```pip install -r requirements.txt```

To activate venv type - VS Code should automatically detect your new venv, so select it as your default interpreter.

```source venv/bin/activate```

## Install package in editable mode

In order to be able to develop and run the code install this repo in editable mode.

```pip install -e .```

# Running

The entry point to profiling the sample object detection models is 
```run_profiling.py``` file.

## Examples

Running on CPU
```python pytorchures/run_profiling.py --device 'cpu' --nr_images 3```

Running on GPU
```python pytorchures/run_profiling.py --device 'cuda' --nr_images 3```

The script will print CPU wall time of every layer encountered in the model.
Values are printed in a nested manner showing deeper layers at further indentation.

# Testing

All tests are located in 'tests' folder. Please follow Arange-Act-Assert pattern for all tests.
The tests should load in the test explorer.

# Formatting

This repo uses 'Black' code formatter.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pytorchures",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "pytorch, performance, layers, profiling",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/b5/9c/4a94bccbca5f781cb9b0e5f02a375296c5ab985f941fcf73e2022be3c6bd/pytorchures-0.0.1.tar.gz",
    "platform": null,
    "description": "# Pytorch profiler\nPytorchures is a simple model profiler intended for any pytorch model. \nIt measures execution time of model layers individually. Every layer of a model is wrapped with timing class which measures latency when called.\n\nTLDR;\n\nInstall\n```\ngit clone https://github.com/cezbloch/pytorchures.git\n\npip install -e .\n```\n\nRun\n```\nfrom pytorchures.timing import wrap_model_layers\n\nwrap_model_layers(model)\n\nmodel(inputs)\n```\n\nExecution time of every layer is stored in ```profiling.log``` file.\n\n# Setup\n\nThis repo was developed under WSL 2 running Ubuntu 20.04 LTS. The editor of choice is VS Code. \n\n## Install python \n\nThe code was tested for Python 3.11 and 3.10, if you want to run Python 3.10 or other future version please subsitute the python version in the command below.\n\nIn case of running new WSL below are required packages and commands.\n\n```sudo apt-get update```\n\n```sudo apt-get install python3.11```\n\n```sudo apt-get install python3.11-venv```\n\nInstall for PIL image.show() to work on WSL\n```sudo apt install imagemagick```\n\n## Install relevant VS Code extentions.\n\nIf you choose to use the recommended VS Code as editor please install the extensions from  ```extensions.json```.\n\n## Create virtual environment\n\nCreate venv \n\n```python3.11 -m venv .venv```\n\nInstall requirements.txt\n\n```pip install -r requirements.txt```\n\nTo activate venv type - VS Code should automatically detect your new venv, so select it as your default interpreter.\n\n```source venv/bin/activate```\n\n## Install package in editable mode\n\nIn order to be able to develop and run the code install this repo in editable mode.\n\n```pip install -e .```\n\n# Running\n\nThe entry point to profiling the sample object detection models is \n```run_profiling.py``` file.\n\n## Examples\n\nRunning on CPU\n```python pytorchures/run_profiling.py --device 'cpu' --nr_images 3```\n\nRunning on GPU\n```python pytorchures/run_profiling.py --device 'cuda' --nr_images 3```\n\nThe script will print CPU wall time of every layer encountered in the model.\nValues are printed in a nested manner showing deeper layers at further indentation.\n\n# Testing\n\nAll tests are located in 'tests' folder. Please follow Arange-Act-Assert pattern for all tests.\nThe tests should load in the test explorer.\n\n# Formatting\n\nThis repo uses 'Black' code formatter.\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2024 Cezary Bloch  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Measure execution time of every layer in your pytorch model.",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/cezbloch/pytorchures"
    },
    "split_keywords": [
        "pytorch",
        " performance",
        " layers",
        " profiling"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9ec29c502813bf6c219411ece9fa4a14b6698ccc489eb46cf3dd4c370e65a8f7",
                "md5": "ca4a8c722b58c461b72134d1672b8f5b",
                "sha256": "dff6e6012e80da67dd444cf70bd51726424abb68f5e479e11c8982a72c80e481"
            },
            "downloads": -1,
            "filename": "pytorchures-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ca4a8c722b58c461b72134d1672b8f5b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 7215,
            "upload_time": "2024-09-26T21:00:05",
            "upload_time_iso_8601": "2024-09-26T21:00:05.201694Z",
            "url": "https://files.pythonhosted.org/packages/9e/c2/9c502813bf6c219411ece9fa4a14b6698ccc489eb46cf3dd4c370e65a8f7/pytorchures-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b59c4a94bccbca5f781cb9b0e5f02a375296c5ab985f941fcf73e2022be3c6bd",
                "md5": "40c7a361333cd6a8ad68ba61d514603b",
                "sha256": "017addc7bb933174897826235f35e5383944b918066ac105acf1371413d1ffd0"
            },
            "downloads": -1,
            "filename": "pytorchures-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "40c7a361333cd6a8ad68ba61d514603b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 7200,
            "upload_time": "2024-09-26T21:00:06",
            "upload_time_iso_8601": "2024-09-26T21:00:06.523877Z",
            "url": "https://files.pythonhosted.org/packages/b5/9c/4a94bccbca5f781cb9b0e5f02a375296c5ab985f941fcf73e2022be3c6bd/pytorchures-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-26 21:00:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cezbloch",
    "github_project": "pytorchures",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pytorchures"
}
        
Elapsed time: 0.47237s