Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
898 Views

Building Media SDK for Ubuntu 18.04.1 Server

Hi,

I've been trying to install the Media SDK on a Ubuntu 18.04.1 machine without any luck.

uname -a

Linux 4.15.0-44-generic #47-Ubuntu SMP Mon Jan 14 11:26:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

cat /proc/cpuinfo

Intel(R) Xeon(R) CPU E3-1225 v5 @ 3.30GHz

So without touching the machine after a fresh install I SSH to it and run my script. The script is divided into two phases with a reboot after the first script.(the scripts are included in the zip file )->

#!/bin/bash
set -e

#Ensure the platform is up to date
sudo apt update && sudo apt -y upgrade && sudo apt -y dist-upgrade

#Install baseline dependencies first (inclusive of OpenCL headers+)
sudo apt-get -y install autoconf automake build-essential libass-dev libtool pkg-config texinfo zlib1g-dev libva-dev cmake mercurial libdrm-dev libvorbis-dev libogg-dev git libx11-dev libperl-dev libpciaccess-dev libpciaccess0 xorg-dev intel-gpu-tools opencl-headers libwayland-dev xutils-dev ocl-icd-*

#Add the Oibaf PPA, needed to install the latest development headers for libva:
sudo add-apt-repository ppa:oibaf/graphics-drivers -y
sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade

#To address linker problems down the line with Ubuntu 18.04LTS:
#https://forum.openframeworks.cc/t/ubuntu-unable-to-compile-missing-glx-mesa/29367/2
if [ -f /usr/lib/x86_64-linux-gnu/libGLX_mesa.so ]; then
   sudo rm /usr/lib/x86_64-linux-gnu/libGLX_mesa.so
fi
sudo ln -s /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0 /usr/lib/x86_64-linux-gnu/libGLX_mesa.so

#Setup build environment:
mkdir -p ~/vaapi

#installing the latest build of libdrm
echo "**************************************"
echo "*** Building and installing libdrm ***"
echo "**************************************"

cd ~/vaapi
git clone https://anongit.freedesktop.org/git/mesa/drm.git libdrm
cd libdrm
./autogen.sh --prefix=/usr --enable-udev
time make -j$(nproc) VERBOSE=1
sudo make -j$(nproc) install
sudo ldconfig -vvvv

#installing the latest build of libdrm
echo "**************************************"
echo "*** Building and installing libva ***"
echo "**************************************"

cd ~/vaapi
git clone https://github.com/01org/libva
cd libva
./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
time make -j$(nproc) VERBOSE=1
sudo make -j$(nproc) install
sudo ldconfig -vvvv

#installing the latest build of gmmlib
echo "**************************************"
echo "*** Building and installing gmmlib ***"
echo "**************************************"

mkdir -p ~/vaapi/workspace
cd ~/vaapi/workspace
git clone https://github.com/intel/gmmlib
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE= Release ../gmmlib
make -j$(nproc)
sudo make -j$(nproc) install 

#installing the latest build of Intel Media driver
echo "***************************************************"
echo "*** Building and installing Intel Media driver: ***"
echo "***************************************************"

cd ~/vaapi/workspace
git clone https://github.com/intel/media-driver
cd media-driver
git submodule init
git pull
mkdir -p ~/vaapi/workspace/build_media
cd ~/vaapi/workspace/build_media
cmake ../media-driver \
-DMEDIA_VERSION="2.0.0" \
-DBS_DIR_GMMLIB=$PWD/../gmmlib/Source/GmmLib/ \
-DBS_DIR_COMMON=$PWD/../gmmlib/Source/Common/ \
-DBS_DIR_INC=$PWD/../gmmlib/Source/inc/ \
-DBS_DIR_MEDIA=$PWD/../media-driver \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=/usr/lib/x86_64-linux-gnu \
-DINSTALL_DRIVER_SYSCONF=OFF \
-DLIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri
time make -j$(nproc) VERBOSE=1
sudo make -j$(nproc) install VERBOSE=1

#Add yourself to the video group:
sudo usermod -a -G video $USER

#export environment variables
#
# TODO: If LIBVA_DRIVERS_PATH or LIBVA_DRIVER_NAME exists.. then replace
#

if [[ -z "${LIBVA_DRIVERS_PATH}" ]]; then
  sudo sh -c "echo 'LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri' >> /etc/environment"
fi
if [[ -z "${LIBVA_DRIVER_NAME}" ]]; then
  sudo sh -c "echo 'LIBVA_DRIVER_NAME=iHD' >> /etc/environment"
fi


#installing the latest build of libva-utils
echo "*******************************************"
echo "*** Building and installing libva-utils ***"
echo "*******************************************"

cd ~/vaapi
git clone https://github.com/intel/libva-utils
cd libva-utils
./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
time make -j$(nproc) VERBOSE=1
sudo make -j$(nproc) install

#reboot
echo 
echo "Reboot system by typing -> sudo reboot now ***"
echo 

Then after the reboot this script is executed ->

#!/bin/bash
set -e

#Build Media SDK 
sudo echo #to avoid the break at sudo make install
cd ~/vaapi
git clone https://github.com/Intel-Media-SDK/MediaSDK msdk
cd msdk
mkdir build && cd build
cmake -DENABLE_OPENCL=OFF ..
make
sudo make install


Everything compiles and installs however when trying to decode using the included sample decoder.. I get this Error->

LD_LIBRARY_PATH=/opt/intel/mediasdk/lib /opt/intel/mediasdk/share/mfx/samples/sample_decode h264 -i myVideo2.nal -o out.yuv

 

[ERROR], sts=MFX_ERR_MEMORY_ALLOC(-4), CreateAllocator, CreateHWDevice failed at /home/netinsight/vaapi/msdk/samples/sample_decode/src/pipeline_decode.cpp:1282

 

[ERROR], sts=MFX_ERR_MEMORY_ALLOC(-4), Init, CreateAllocator failed at /home/netinsight/vaapi/msdk/samples/sample_decode/src/pipeline_decode.cpp:425

 

[ERROR], sts=MFX_ERR_MEMORY_ALLOC(-4), main, Pipeline.Init failed at /home/netinsight/vaapi/msdk/samples/sample_decode/src/sample_decode.cpp:676

So obviously the Media SDK is not working as expected. Has anyone successfully installed the Media SDK on a Ubuntu 18.04.1? What am I doing wrong?

 

Thanks for any assistance.

 

/Anders

0 Kudos
5 Replies
Highlighted
Moderator
898 Views

Hi Anders,

It looks like you are trying to build the Open Source Media SDK, on Ubuntu 18.04 and E3-1225 v5(SkyLake). I think this configuration should be qualified for the system requirement.

From the output error message, the installation should be OK because it failed at memory allocation. How do you get the input file? As you know we required elementary stream. If you have the sample binary, the quick try is to use the test video clip in the binary. You can find it in the following way:

1. Download the binary package from the release page: https://github.com/Intel-Media-SDK/MediaSDK/releases

2. Unzip the package and you will find a "tests" folder, the video should be in ~/tests/content.

You can use the file "test_stream.264" to replace your original file to see if you can run it successfully.

Mark

0 Kudos
Highlighted
898 Views

Mark,

Thank you for the quick responce. I did download the binary and locate the "test_stream.264" file.

Then I ran the same command again -> LD_LIBRARY_PATH=/opt/intel/mediasdk/lib /opt/intel/mediasdk/share/mfx/samples/sample_decode h264 -i test_stream.264 -o out.yuv

However I got the same output ->

[ERROR], sts=MFX_ERR_MEMORY_ALLOC(-4), CreateAllocator, CreateHWDevice failed at /home/netinsight/vaapi/msdk/samples/sample_decode/src/pipeline_decode.cpp:1282

 

[ERROR], sts=MFX_ERR_MEMORY_ALLOC(-4), Init, CreateAllocator failed at /home/netinsight/vaapi/msdk/samples/sample_decode/src/pipeline_decode.cpp:425

 

[ERROR], sts=MFX_ERR_MEMORY_ALLOC(-4), main, Pipeline.Init failed at /home/netinsight/vaapi/msdk/samples/sample_decode/src/sample_decode.cpp:676

I Think there is something more fundamentally wrong with the installation since vainfo returns a lot of errors. But I don't know where to start looking.

vainfo
error: can't connect to X server!
libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns -1
libva info: User requested driver 'iHD'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_4
DRM_IOCTL_I915_GEM_APERTURE failed: Invalid argument
Assuming 131072kB available aperture size.
May lead to reduced performance or incorrect rendering.
get chip id failed: -1 [22]
param: 4, val: 0
libva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
libva info: va_openDriver() returns 1
vaInitialize failed with error code 1 (operation failed),exit

/Anders

 

0 Kudos
Highlighted
Moderator
898 Views

Yes, from the output vainfo, it tells me it doesn't connect to the i915 driver.

Did you set the followings?

export LIBVA_DRIVER_NAME=iHD

export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri

You can also refer to my article at the following URL for how to validate the build/installation:

https://software.intel.com/en-us/articles/build-and-debug-open-source-media-stack

This article also tells you what the expected output of vainfo.

Mark

0 Kudos
Highlighted
898 Views

Hi,

Found the problem. It was a setting in my system, a BIOS setting suppressing the Intel graphics in favour for some on board VGA graphics card. I did also modify my script including the current (hopefully working) commit hashes. The script installs Intel Media SDK and all dependencies on a fresh installed Ubuntu 18.04.1 Server.

Step 1.

Install Ubuntu 18.04.1

Step 2.

Log in and run ->

sudo apt update && sudo apt -y upgrade && sudo apt -y dist-upgrade

Step 3.

Reboot by typing -> sudo reboot now

Step 4. 

Copy the below script to your local machine and name it  'install_msdk.sh' then send it to the home directory (Or any other) on the MSDK machine by for example using scp

scp install_msdk.sh (your user)@(the server ip):~/.

OBSERVE!!!!!! you need to make one modification. the line where it says *sudo usermod -a -G video (Your User)*

you need to enter your user so if your user is: megadeveloper the line should read: sudo usermod -a -G video megadeveloper

 

 

#!/bin/bash
set -e

#uname -a
#inux 4.4.0-141-generic #167-Ubuntu SMP Wed Dec 5 10:40:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

#Ensure the platform is up to date
##sudo apt update && sudo apt -y upgrade && sudo apt -y dist-upgrade

# reboot -> sudo reboot now

# install dependencies 
sudo apt-get install -y gdb build-essential cmake autoconf libtool libdrm-dev pkg-config libpciaccess-dev xutils-dev libx11-dev xorg-dev

#Remove build environment if it already exists
rm -rf ~/vaapi

#Setup build environment:
mkdir ~/vaapi

#installing the latest build of libva
echo "**************************************"
echo "*** Building and installing libva  ***"
echo "**************************************"

cd ~/vaapi
git clone https://github.com/intel/libva.git
cd libva
#git co 0dc70068e49f9538fbd03f2f0aa1e56a91e986e7
./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
time make -j$(nproc)
sudo make -j$(nproc) install

#installing the latest build of gmmlib
echo "**************************************"
echo "*** Building and installing gmmlib ***"
echo "**************************************"

mkdir -p ~/vaapi/
cd ~/vaapi/
git clone https://github.com/intel/gmmlib
#cd gmmlib
#git co bcac3f3833ed7944526a93845893bd80a3fc30cc
#cd ..
mkdir -p build_gmm
cd build_gmm
cmake -DCMAKE_BUILD_TYPE=Release ../gmmlib
make -j$(nproc)
sudo make -j$(nproc) install 

#installing the latest build of libdrm
echo "**************************************"
echo "*** Building and installing libdrm ***"
echo "**************************************"

cd ~/vaapi
git clone https://anongit.freedesktop.org/git/mesa/drm.git libdrm
cd libdrm
#git co b7a7a90336fbb19efb3f91f92b5d964b0dfb7ec2
./autogen.sh --prefix=/usr --enable-udev
time make -j$(nproc)
sudo make -j$(nproc) install
sudo ldconfig -vvvv


#installing the latest build of media driver
echo "*********************************************"
echo "*** Building and installing media driver  ***"
echo "*********************************************"
cd ~/vaapi
git clone https://github.com/intel/media-driver.git
#cd media-driver
#git co f34518439b1803c753e28ceb34fecc64cea0ce31
#cd ..
mkdir build_media
cd build_media
cmake -DCMAKE_INSTALL_PREFIX=/usr ../media-driver

#(If building debug or release internal version, please use this command: 
#cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TYPE=release-internal ../media-driver)

time make -j$(nproc) 
sudo make -j$(nproc) install

#export environment variables
#
# TODO: If LIBVA_DRIVERS_PATH or LIBVA_DRIVER_NAME exists.. then replace
#

if [[ -z "${LIBVA_DRIVERS_PATH}" ]]; then
  sudo sh -c "echo 'LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri' >> /etc/environment"
fi
if [[ -z "${LIBVA_DRIVER_NAME}" ]]; then
  sudo sh -c "echo 'LIBVA_DRIVER_NAME=iHD' >> /etc/environment"
fi

sudo usermod -a -G video (Your User)

#reboot
echo 
echo "Reboot system by typing -> sudo reboot now ***"
echo 


step 5.

Login to your MSDK machine after the reboot.

Ping the machine by -> ping (ip) 

To see when you can login again

step 6.

make the script executable by ->

chmod +x install_msdk.sh

then

./install_msdk.sh

Step 7.

when the script ended reboot by ->

sudo reboot now

Step 8.

Login to your MSDK machine after the reboot.

Ping the machine by -> ping (ip) 

To see when you can login again

Step9.

Copy the below script to your local machine and name it  'install_msdk2.sh' then send it to the home directory (Or any other) on the MSDK machine by for example using scp

scp install_msdk2.sh (your user)@(the server ip):~/.

#!/bin/bash
set -e

#installing the latest build of Media SDK 
echo "******************************************"
echo "*** Building and installing Media SDK  ***"
echo "******************************************"

sudo echo #to avoid the break at sudo make install
cd ~/vaapi
git clone https://github.com/Intel-Media-SDK/MediaSDK msdk
cd msdk
#git co 3d33f3c88e659f9f04409f46ce91778beab1b5a4
mkdir build && cd build
cmake -DBUILD_TESTS=ON -DBUILD_TOOLS=ON ..
time make -j$(nproc)
sudo make -j$(nproc) install

step 9.

make the script executable by ->

chmod +x install_msdk2.sh

then

./install_msdk2.sh

Step 10.

Done!

 

Verify by downloading the file test_stream.264 (see marks comment above -> )->

(The location of the file is : MediaStack/opt/intel/mediasdk/share/mfx/samples/_bin/content)

Execute the below line where you did put the 'test_stream.264' file

LD_LIBRARY_PATH=/opt/intel/mediasdk/lib /opt/intel/mediasdk/share/mfx/samples/sample_decode h264 -i test_stream.264 -o out.yuv

I then get ->

LD_LIBRARY_PATH=/opt/intel/mediasdk/lib /opt/intel/mediasdk/share/mfx/samples/sample_decode h264 -i test_stream.264 -o out.yuv
libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_4
libva info: va_openDriver() returns 0
Decoding Sample Version 8.3.26.


Input video    AVC 
Output format    NV12
Input:
  Resolution    176x96
  Crop X,Y,W,H    0,0,176,96
Output:
  Resolution    176x96
Frame rate    30.00
Memory type        system
MediaSDK impl        hw
MediaSDK version    1.28

Decoding started
Frame number:  101, fps: 1982.803, fread_fps: 0.000, fwrite_fps: 0.000
Decoding finished

 

That's it.... Have fun :-)

 

/Anders

0 Kudos
Highlighted
Beginner
97 Views

I tried the steps you have listed, and they all worked fine except the libdrm had to be built by meson since there was no autogen.sh. Rest all flowed smoothy.

 

However, after running the sample_decode command, I get this error: Could you pls let me know what could be wrong, or any other information I need to provide:

lenovo@lenovo-Lenovo-G570:~/vandana/tvinabox/vaapi$ LD_LIBRARY_PATH=/opt/intel/mediasdk/lib /opt/intel/mediasdk/share/mfx/samples/sample_decode h264 -i test_stream.264 -o out.yuv
libva info: VA-API version 1.10.0
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_10
[MOS]: CRITICAL - HWInfo_GetGfxInfo:143: Failed to get the device info for Device id: 116

[LIBVA]:CRITICAL - DdiMedia__Initialize:1762: Fatal error - unsuccesfull Sku/Wa/GtSystemInfo initialization
libva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
libva info: va_openDriver() returns 1

[ERROR], sts=MFX_ERR_MEMORY_ALLOC(-4), Init, CreateHWDevice failed at /home/lenovo/vandana/tvinabox/vaapi/msdk/samples/sample_decode/src/pipeline_decode.cpp:439

[ERROR], sts=MFX_ERR_MEMORY_ALLOC(-4), main, Pipeline.Init failed at /home/lenovo/vandana/tvinabox/vaapi/msdk/samples/sample_decode/src/sample_decode.cpp:773

0 Kudos