Skip to content

Commit

Permalink
Added README
Browse files Browse the repository at this point in the history
  • Loading branch information
a-sidorova committed Nov 19, 2023
1 parent 10894e6 commit e20207f
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions src/build_scripts/openvino/riscv-64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# OpenVINO Cross-Compilation for RISC-V

## Build using Docker

Install and configure Docker using [guide](../../../../docker/README).

Build Docker image.

```
docker build -t openvino_riscv .
```

Run temporary Docker container using the built image to
copy the installed OpenVINO libraries on host machine.

```
docker run -t openvino_riscv
docker cp <container_name>:/openvino_riscv64_gnu .
```

Archive the folder `openvino_riscv64_gnu` and copy on the target
platform RISC-V using `scp` utility or USB flash drive.

```
tar -cvf openvino_riscv64_gnu.tar openvino_riscv64_gnu/
scp openvino_riscv64_gnu.tar <user>@<address>:<path>
```

On the target platform unarchive the files and activate OpenVINO environment.

```
tar -xvf openvino_riscv64_gnu.tar
source openvino_riscv64_gnu/setupvars.sh
```

To check correctness of build try to import `openvino` package.

```
python3 -c 'import openvino'
```


## Manual build

Clone [OpenVINO][ov_repo] repository.

```
git clone https://github.com/openvinotoolkit/openvino.git --branch 2023.2.0 && cd openvino
git submodule update --init \
./thirdparty/pugixml \
./thirdparty/ade \
./thirdparty/gflags/gflags \
./thirdparty/protobuf \
./thirdparty/json/nlohmann_json \
./thirdparty/flatbuffers/flatbuffers \
./thirdparty/onnx/onnx \
./thirdparty/snappy \
./thirdparty/zlib \
./thirdparty/open_model_zoo \
./src/plugins/intel_cpu/thirdparty/onednn \
./src/bindings/python/thirdparty/pybind11
```

Install RISC-V packages.

```
sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu crossbuild-essential-riscv64
sudo dpkg --add-architecture riscv64
sudo sed -i -E 's|^deb ([^ ]+) (.*)$|deb [arch=amd64] \1 \2\ndeb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ \2|' /etc/apt/sources.list
apt update -y && apt install -y --no-install-recommends libpython3-dev:riscv64
```

Install python requirements.

```
python3 -m pip install -r ./src/bindings/python/wheel/requirements-dev.txt
python3 -m pip install -r ./src/bindings/python/src/compatibility/openvino/requirements-dev.txt
```

Copy custom CMake toolchain file to repository.

```
cp <path>/custom_riscv64.toolchain.cmake <path>/openvino/cmake/toolchains/custom_riscv64.toolchain.cmake
```

Build OpenVINO from source.

```
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../openvino_riscv64_gnu \
-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/custom_riscv64.toolchain.cmake \
-DENABLE_INTEL_CPU=ON -DENABLE_INTEL_GPU=OFF -DENABLE_INTEL_GNA=OFF -DENABLE_MULTI=OFF -DENABLE_AUTO=OFF -DENABLE_HETERO=OFF \
-DENABLE_PYTHON=ON -DPYTHON_MODULE_EXTENSION=$(riscv64-linux-gnu-python3-config --extension-suffix) \
-DPYBIND11_PYTHON_EXECUTABLE_LAST=/usr/bin/python3.10 -DENABLE_PYTHON_PACKAGING=ON
make install -j $(proc)
rm -rf ./build
```

The build OpenVINO libraries are stored in the folder `openvino_riscv64_gnu`.
To copy these files, follow the instructions in the 'Building with Docker' section above.


## Notes

Please note that the versions of Python used to build the OpenVINO Python API and those installed on the RISC-V platform must be the same.


<!-- LINKS -->
[ov_repo]: https://github.com/openvinotoolkit/openvino

0 comments on commit e20207f

Please sign in to comment.