The wikis are now using the new authentication system.
If you did not migrate your account yet, visit https://idp-portal-info.suse.com/

SDB:Install GNA in NUC Beast Canyon

Jump to: navigation, search
gna.

Intel has integrated AI capabilities right into the PC processor to meet the growing demand for modern software applications. Whether it’s existing applications getting smarter or entirely new tools, the latest intelligent PCs bring you dedicated performance for the deep neural networks that form the foundation of AI applications.

This feature was named GNA (Gaussian & Neural Accelerator Library ), and we'll learn how to use it on openSUSE with this text.

You’ll also get more immersive collaboration experiences, including neural noise suppression, background blur, video super-resolution, and the latest video codec in personal computer. The Beast Canyon NUC is the computer used in this article with Core i9-11900KB processor.


What is GNA?

Intel® Gaussian & Neural Accelerator is a low-power neural coprocessor for continuous inference at the edge.

When power and performance are critical, the Intel® Gaussian & Neural Accelerator (Intel® GNA) provides power-efficient, always-on support. Intel® GNA is designed to deliver AI speech and audio applications such as neural noise cancellation, while simultaneously freeing up CPU resources for overall system performance and responsiveness.

Package Requirements

Install CMake*, pkg-config, kernel devel, and GNU* Dev Tools to Build Samples.The compilers utilize the existing GNU build toolchains to provide a complete C/C++ development environment. If your distribution of Linux does not include the complete suite of GNU development tools, you need to install these tools. To install the GNU development tools on your Linux system, open a terminal session and enter the following commands:

$ sudo zypper update
$ sudo zypper --non-interactive install cmake pkg-config
$ sudo zypper --non-interactive install pattern devel_C_C++
$ sudo zypper --non-interactive install patterns-devel-base-devel_kernel

Verify the installation by displaying the installation location with this command:

$ which cmake pkg-config make gcc g++

One or more of these locations will display:

/usr/bin/cmake
/usr/bin/pkg-config
/usr/bin/make
/usr/bin/gcc
/usr/bin/g++

Build and Install GNA Driver Kernel Module

Following the example below, create folder, enter in this folder, use the command wget to download the source code from the Intel OpenVINO ToolKit repository.

$ mkdir gna
$ cd gna
$ wget https://storage.openvinotoolkit.org/drivers/gna/gna-drv-linux-1.2.3.zip
--2021-08-30 09:50:09--  https://storage.openvinotoolkit.org/drivers/gna/gna-drv-linux-1.2.3.zip
Resolvendo storage.openvinotoolkit.org (storage.openvinotoolkit.org)... 2600:9000:20ac:a800:8:6691:6300:93a1, 2600:9000:20ac:9c00:8:6691:6300:93a1, 2600:9000:20ac:8a00:8:6691:6300:93a1, ...
Conectando-se a storage.openvinotoolkit.org (storage.openvinotoolkit.org)|2600:9000:20ac:a800:8:6691:6300:93a1|:443... conectado.
A requisi??o HTTP foi enviada, aguardando resposta... 200 OK
Tamanho: 26542 (26K) [application/zip]
Salvando em: ?gna-drv-linux-1.2.3.zip?

gna-drv-linux-1.2.3.zip      100%[======================================================>]  25,92K   144KB/s em 0,2s    

2021-08-30 09:50:10 (144 KB/s) - ?gna-drv-linux-1.2.3.zip? salvo [26542/26542]

Now extract the files with the command unzip and tar as shown below.

$ unzip gna-drv-linux-1.2.3.zip 
Archive:  gna-drv-linux-1.2.3.zip
  inflating: fromUpstreamV2.patch    
 extracting: gna-drv-mod.1.2.3.tar.bz2  
  inflating: license.txt             
  inflating: release_notes.txt       

$ tar -axvf gna-drv-mod.1.2.3.tar.bz2
gna-drv-mod.1.2.3/
gna-drv-mod.1.2.3/gna_driver.h
gna-drv-mod.1.2.3/gna_kcompat.h
gna-drv-mod.1.2.3/gna_device.c
gna-drv-mod.1.2.3/gna_request.h
gna-drv-mod.1.2.3/gna_ioctl.h
gna-drv-mod.1.2.3/gna_hw.c
gna-drv-mod.1.2.3/gna_score.h
gna-drv-mod.1.2.3/sample_install.sh
gna-drv-mod.1.2.3/readme
gna-drv-mod.1.2.3/gna_mem.c
gna-drv-mod.1.2.3/Makefile
gna-drv-mod.1.2.3/gna_ioctl.c
gna-drv-mod.1.2.3/gna_driver.c
gna-drv-mod.1.2.3/gna_hw.h
gna-drv-mod.1.2.3/gna_request.c
gna-drv-mod.1.2.3/gna_mem.h
gna-drv-mod.1.2.3/include/
gna-drv-mod.1.2.3/include/uapi/
gna-drv-mod.1.2.3/include/uapi/misc/
gna-drv-mod.1.2.3/include/uapi/misc/intel/
gna-drv-mod.1.2.3/include/uapi/misc/intel/gna.h
gna-drv-mod.1.2.3/gna_score.c
gna-drv-mod.1.2.3/gna.rst
gna-drv-mod.1.2.3/gna_device.h

After extracting the files, enter the newly created folder (gna-drv-mod.1.2.3). Then run the make command and run the sample_install.sh script.

$ make
make -C /lib/modules/5.3.18-59.19-default/build M=/tmp/gna/gna-drv-mod.1.2.3
make[1]: Entering directory '/usr/src/linux-5.3.18-59.19-obj/x86_64/default'
  CC [M]  /tmp/gna/gna-drv-mod.1.2.3/gna_device.o
  CC [M]  /tmp/gna/gna-drv-mod.1.2.3/gna_driver.o
  CC [M]  /tmp/gna/gna-drv-mod.1.2.3/gna_hw.o
  CC [M]  /tmp/gna/gna-drv-mod.1.2.3/gna_ioctl.o
  CC [M]  /tmp/gna/gna-drv-mod.1.2.3/gna_mem.o
  CC [M]  /tmp/gna/gna-drv-mod.1.2.3/gna_request.o
  CC [M]  /tmp/gna/gna-drv-mod.1.2.3/gna_score.o
  LD [M]  /tmp/gna/gna-drv-mod.1.2.3/intel_gna.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /tmp/gna/gna-drv-mod.1.2.3/intel_gna.mod.o
  LD [M]  /tmp/gna/gna-drv-mod.1.2.3/intel_gna.ko
make[1]: Leaving directory '/usr/src/linux-5.3.18-59.19-obj/x86_64/default'


$ sudo ./sample_install.sh
[sudo] senha para root: 
Warning: Unsupported kernel version. Proceed? y
Installing intel_gna driver module ...
make -C /lib/modules/5.3.18-59.19-default/build M=/tmp/gna/gna-drv-mod.1.2.3
make[1]: Entering directory '/usr/src/linux-5.3.18-59.19-obj/x86_64/default'
  Building modules, stage 2.
  MODPOST 1 modules
make[1]: Leaving directory '/usr/src/linux-5.3.18-59.19-obj/x86_64/default'
intel_gna driver module installation completed successfully.

To check if the module was compiled and installed correctly, use the lsmod command like the following example.

$ sudo lsmod|grep gna
intel_gna              45056  0

Build and Run the GNA - Gaussian & Neural Accelerator Library

Following the example below, use the command git clone to download the source code from the github repository.

$ git clone https://github.com/intel/gna
Cloning into 'gna'...
remote: Enumerating objects: 335, done.
remote: Counting objects: 100% (335/335), done.
remote: Compressing objects: 100% (255/255), done.
remote: Total 335 (delta 83), reused 329 (delta 77), pack-reused 0
Receiving objects: 100% (335/335), 405.07 KiB | 3.65 MiB/s, done.
Resolving deltas: 100% (83/83), done.

Now enter the newly created folder again and use the command cmake and make as in the example below.

$ cmake .
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cabelo/gna/gna-drv-mod.1.2.3/gna

$ make 

Build and Run the SDK/Examples Using the Command Line

Following the example below, enter in samples folder and use the commands mkdir, cd and cmake for build the SDK example.

$ cmake .
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/gna/gna-drv-mod.1.2.3/gna/samples

$ make
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/gna/gna-drv-mod.1.2.3/gna/samples
Scanning dependencies of target sample01
[ 50%] Building CXX object src/sample01/CMakeFiles/sample01.dir/sample01.cpp.o
[100%] Linking CXX executable ../../bin/sample01/sample01
[100%] Built target sample01

Now to run the example below the commands.

cd bin/sample01
./sample01 
GNA Hardware Device found: 32

Outputs:
-177    -85     29      28
96      -173    25      252
-160    274     157     -29
48      -60     158     -29
26      -2      -44     -251
-173    -70     -1      -323
99      144     38      -63
20      56      -103    10

This text was built by Official oneAPI Innovator Intel and openSUSE member Alessandro de Oliveira Faria based on Intel tutorials. More information see the official page HERE