ncnn-riscv-wheel


Namencnn-riscv-wheel JSON
Version 1.0.20240706 PyPI version JSON
download
home_pagehttps://github.com/per1cycle/ncnn-riscv-wheel
Summaryncnn is a high-performance neural network inference framework optimized for the mobile platform
upload_time2024-07-06 02:15:01
maintainerper1cycle
docs_urlNone
authornihui
requires_python>=3.5
licenseBSD-3
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ncnn
python wrapper of ncnn with [pybind11](https://github.com/pybind/pybind11), only support python3.x now.


Install from pip
==================

ncnn is available as wheel packages for macOS, Windows and Linux distributions, you can install with pip:

```
python -m pip install -U pip
python -m pip install -U ncnn
```

# Build from source

If you want to build ncnn with some options not as default, or just like to build everything yourself, it is not difficult to build ncnn from source.

## Prerequisites

**On Unix (Linux, OS X)**

* A compiler with C++11 support
* CMake >= 3.4

**On Mac**

* A compiler with C++11 support
* CMake >= 3.4

**On Windows**

* Visual Studio 2015 or higher
* CMake >= 3.4

##  Build & Install

1. clone ncnn and init submodule.

```bash
cd /pathto/ncnn
git submodule init && git submodule update
```

2. build and install.

```
python setup.py install
```

If you want to use a custom toolchain, you can install with the `CMAKE_TOOLCHAIN_FILE` environment variable, like this:

```
CMAKE_TOOLCHAIN_FILE="../../toolchains/power9le-linux-gnu-vsx.clang.toolchain.cmake" python setup.py install
```

if you want to enable the usage of vulkan, you can install as following:

```
python setup.py install --vulkan=on
```

> **Attention:**
>
> To enable Vulkan support, you must first install the Vulkan SDK.
>
> **For Windows or Linux Users:**
>
> Ensure that the `VULKAN_SDK` environment variable is set to the path of the Vulkan SDK.
>
> **For MacOS Users:**
>
> On MacOS, you will need to specify additional environment variables. For guidance on setting these variables, please refer to lines 279-286 in the following file: [ncnn/.github/workflows/release-python.yml at master ยท Tencent/ncnn](https://github.com/Tencent/ncnn/blob/master/.github/workflows/release-python.yml).

## Custom-build & Install

1. clone ncnn and init submodule.
```bash
cd /pathto/ncnn
git submodule init && git submodule update
```
2. build.
```bash
mkdir build
cd build
cmake -DNCNN_PYTHON=ON ..
make
```

3. install

```bash
cd /pathto/ncnn
pip install .
```

if you use conda or miniconda, you can also install as following:
```bash
cd /pathto/ncnn
python3 setup.py install
```

## Tests

**test**
```bash
cd /pathto/ncnn/python
python3 tests/test.py
```

**benchmark**

```bash
cd /pathto/ncnn/python
python3 tests/benchmark.py
```

## Numpy
**ncnn.Mat->numpy.array, with no memory copy**

```bash
mat = ncnn.Mat(...)
mat_np = np.array(mat)
```

**numpy.array->ncnn.Mat, with no memory copy**
```bash
mat_np = np.array(...)
mat = ncnn.Mat(mat_np)
```

# Model Zoo
install requirements
```bash
pip install -r requirements.txt
```
then you can import ncnn.model_zoo and get model list as follow:
```bash
import ncnn
import ncnn.model_zoo as model_zoo

print(model_zoo.get_model_list())
```
models now in model zoo are as list below:
```bash
mobilenet_yolov2
mobilenetv2_yolov3
yolov4_tiny
yolov4
yolov5s
yolact
mobilenet_ssd
squeezenet_ssd
mobilenetv2_ssdlite
mobilenetv3_ssdlite
squeezenet
faster_rcnn
peleenet_ssd
retinaface
rfcn
shufflenetv2
simplepose
nanodet
```
all model in model zoo has example in ncnn/python/examples folder

# Custom Layer

custom layer demo is in ncnn/python/ncnn/model_zoo/yolov5.py:23

# *new*
i build the wheel on debian 13 riscv, all test passed.
*Recommend python version: 3.11*
install from pypi~
you can now install direc in riscv machiene!
```bash
pip install ncnn-riscv-wheel
# or install from release site! https://github.com/per1cycle/ncnn-riscv-wheel/releases
pip install https://github.com/per1cycle/ncnn-riscv-wheel/releases/download/ncnn-cp311-linux-riscv-wheel/ncnn-1.0.20240704-cp311-cp311-linux_riscv64.whl
```

*Alternative*
install from source:
```bash
apt update
apt install gcc g++ make autoconf automake cmake python3-pip python3-numpy python3-setuptools git vim python3.11-full ninja-build libpython3.11-dev libssl-dev python3-pip python3-setuptools

git clone --recurse-submodules https://github.com/Tencent/ncnn 
cd ncnn
mkdir build 
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DNCNN_BUILD_BENCHMARK=ON -DNCNN_PYTHON=ON -DNCNN_BUILD_TESTS=ON ..

make -j4
cd ..
cd python 
python setup.py bdist_wheel
export MAKEFLAGS=-j$(nproc) && python3 -m pip install ncnn-1.0.20240704-cp311-cp311-linux_riscv64.whl --break-system-packages --verbose
# or 
pip install dist/<xxx>.whl --break-system-packages

# check if the installation is fine.
pip list | grep ncnn

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/per1cycle/ncnn-riscv-wheel",
    "name": "ncnn-riscv-wheel",
    "maintainer": "per1cycle",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "pericycle.cc@gmail.com",
    "keywords": null,
    "author": "nihui",
    "author_email": "nihuini@tencent.com",
    "download_url": "https://files.pythonhosted.org/packages/18/7b/995c1fc9879d527cfe736f3f438bf3ba8317e39077ea95ccbeef39ef47b0/ncnn-riscv-wheel-1.0.20240706.tar.gz",
    "platform": null,
    "description": "# ncnn\npython wrapper of ncnn with [pybind11](https://github.com/pybind/pybind11), only support python3.x now.\n\n\nInstall from pip\n==================\n\nncnn is available as wheel packages for macOS, Windows and Linux distributions, you can install with pip:\n\n```\npython -m pip install -U pip\npython -m pip install -U ncnn\n```\n\n# Build from source\n\nIf you want to build ncnn with some options not as default, or just like to build everything yourself, it is not difficult to build ncnn from source.\n\n## Prerequisites\n\n**On Unix (Linux, OS X)**\n\n* A compiler with C++11 support\n* CMake >= 3.4\n\n**On Mac**\n\n* A compiler with C++11 support\n* CMake >= 3.4\n\n**On Windows**\n\n* Visual Studio 2015 or higher\n* CMake >= 3.4\n\n##  Build & Install\n\n1. clone ncnn and init submodule.\n\n```bash\ncd /pathto/ncnn\ngit submodule init && git submodule update\n```\n\n2. build and install.\n\n```\npython setup.py install\n```\n\nIf you want to use a custom toolchain, you can install with the `CMAKE_TOOLCHAIN_FILE` environment variable, like this:\n\n```\nCMAKE_TOOLCHAIN_FILE=\"../../toolchains/power9le-linux-gnu-vsx.clang.toolchain.cmake\" python setup.py install\n```\n\nif you want to enable the usage of vulkan, you can install as following:\n\n```\npython setup.py install --vulkan=on\n```\n\n> **Attention:**\n>\n> To enable Vulkan support, you must first install the Vulkan SDK.\n>\n> **For Windows or Linux Users:**\n>\n> Ensure that the `VULKAN_SDK` environment variable is set to the path of the Vulkan SDK.\n>\n> **For MacOS Users:**\n>\n> On MacOS, you will need to specify additional environment variables. For guidance on setting these variables, please refer to lines 279-286 in the following file: [ncnn/.github/workflows/release-python.yml at master \u00b7 Tencent/ncnn](https://github.com/Tencent/ncnn/blob/master/.github/workflows/release-python.yml).\n\n## Custom-build & Install\n\n1. clone ncnn and init submodule.\n```bash\ncd /pathto/ncnn\ngit submodule init && git submodule update\n```\n2. build.\n```bash\nmkdir build\ncd build\ncmake -DNCNN_PYTHON=ON ..\nmake\n```\n\n3. install\n\n```bash\ncd /pathto/ncnn\npip install .\n```\n\nif you use conda or miniconda, you can also install as following:\n```bash\ncd /pathto/ncnn\npython3 setup.py install\n```\n\n## Tests\n\n**test**\n```bash\ncd /pathto/ncnn/python\npython3 tests/test.py\n```\n\n**benchmark**\n\n```bash\ncd /pathto/ncnn/python\npython3 tests/benchmark.py\n```\n\n## Numpy\n**ncnn.Mat->numpy.array, with no memory copy**\n\n```bash\nmat = ncnn.Mat(...)\nmat_np = np.array(mat)\n```\n\n**numpy.array->ncnn.Mat, with no memory copy**\n```bash\nmat_np = np.array(...)\nmat = ncnn.Mat(mat_np)\n```\n\n# Model Zoo\ninstall requirements\n```bash\npip install -r requirements.txt\n```\nthen you can import ncnn.model_zoo and get model list as follow:\n```bash\nimport ncnn\nimport ncnn.model_zoo as model_zoo\n\nprint(model_zoo.get_model_list())\n```\nmodels now in model zoo are as list below:\n```bash\nmobilenet_yolov2\nmobilenetv2_yolov3\nyolov4_tiny\nyolov4\nyolov5s\nyolact\nmobilenet_ssd\nsqueezenet_ssd\nmobilenetv2_ssdlite\nmobilenetv3_ssdlite\nsqueezenet\nfaster_rcnn\npeleenet_ssd\nretinaface\nrfcn\nshufflenetv2\nsimplepose\nnanodet\n```\nall model in model zoo has example in ncnn/python/examples folder\n\n# Custom Layer\n\ncustom layer demo is in ncnn/python/ncnn/model_zoo/yolov5.py:23\n\n# *new*\ni build the wheel on debian 13 riscv, all test passed.\n*Recommend python version: 3.11*\ninstall from pypi~\nyou can now install direc in riscv machiene!\n```bash\npip install ncnn-riscv-wheel\n# or install from release site! https://github.com/per1cycle/ncnn-riscv-wheel/releases\npip install https://github.com/per1cycle/ncnn-riscv-wheel/releases/download/ncnn-cp311-linux-riscv-wheel/ncnn-1.0.20240704-cp311-cp311-linux_riscv64.whl\n```\n\n*Alternative*\ninstall from source:\n```bash\napt update\napt install gcc g++ make autoconf automake cmake python3-pip python3-numpy python3-setuptools git vim python3.11-full ninja-build libpython3.11-dev libssl-dev python3-pip python3-setuptools\n\ngit clone --recurse-submodules https://github.com/Tencent/ncnn \ncd ncnn\nmkdir build \ncd build\ncmake -DCMAKE_BUILD_TYPE=Release -DNCNN_BUILD_BENCHMARK=ON -DNCNN_PYTHON=ON -DNCNN_BUILD_TESTS=ON ..\n\nmake -j4\ncd ..\ncd python \npython setup.py bdist_wheel\nexport MAKEFLAGS=-j$(nproc) && python3 -m pip install ncnn-1.0.20240704-cp311-cp311-linux_riscv64.whl --break-system-packages --verbose\n# or \npip install dist/<xxx>.whl --break-system-packages\n\n# check if the installation is fine.\npip list | grep ncnn\n\n```\n",
    "bugtrack_url": null,
    "license": "BSD-3",
    "summary": "ncnn is a high-performance neural network inference framework optimized for the mobile platform",
    "version": "1.0.20240706",
    "project_urls": {
        "Homepage": "https://github.com/per1cycle/ncnn-riscv-wheel"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "187b995c1fc9879d527cfe736f3f438bf3ba8317e39077ea95ccbeef39ef47b0",
                "md5": "1e48556fa8707524003a765b384d8b68",
                "sha256": "c7da8b937d07f086fb5374c5806e4a59291a1872654fbac78179f1509fc41c7c"
            },
            "downloads": -1,
            "filename": "ncnn-riscv-wheel-1.0.20240706.tar.gz",
            "has_sig": false,
            "md5_digest": "1e48556fa8707524003a765b384d8b68",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 695289,
            "upload_time": "2024-07-06T02:15:01",
            "upload_time_iso_8601": "2024-07-06T02:15:01.793412Z",
            "url": "https://files.pythonhosted.org/packages/18/7b/995c1fc9879d527cfe736f3f438bf3ba8317e39077ea95ccbeef39ef47b0/ncnn-riscv-wheel-1.0.20240706.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-06 02:15:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "per1cycle",
    "github_project": "ncnn-riscv-wheel",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ncnn-riscv-wheel"
}
        
Elapsed time: 0.65958s