Step by step to enable x264 with OpenCL – NVIDIA solution


x264 project added OpenCL video acceleration to it’s implementation early at about 2013(not sure with the date), and my goal here is test the video encoding performance of x264 when with OpenCL video accelerator enabled.

Test hardware environments: HP Pavilion 14
1. Graphic card: NVIDIA GeForce GT730M card.
2. CPU: Intel Core Ivy Bridge i7-3632QM

Here we go.

1. Install OS: Ubuntu 14.10 64 bit version
2. Install g++ cmake yasm

3. Update graphic driver to NVIDIA version 331.89
4. Some preparation for the tests *If you already have a YUV file, you can skip the ffmpeg related steps.
a. Download source code: x264, ffmpeg
b. Compile x264

c. Compile ffmpeg

c. Use the newly compiled ffmpeg to decode a video file to yuv

5. Check whether my graphic driver support opencl
First install clinfo:

however, running clinfo return with a message like this:

Never mind, according to my hardware environment, I have two ways to run the test: Intel graphic drive and NVIDIA graphic driver. However, I’ll test NVIDIA solution first.

——————————————————–
NVIDIA solution
1. Download CUDA 7.0 Toolkit
Go visit NVIDIA web site(http://www.nvidia.com/getcuda) and download a copy of CUDA ToolKit 7.0. I choosed cuda_7.0.28_linux-ubuntu.run
Downloaded a CUDA 7.0 Toolkit, 1.1 GB, took me 4 hours, about 20+KB per second, seems it’s me whose network sucked.

2. Install CUDA 7.0 Toolkit
Excute cuda_7.0.28_linux-ubuntu.run directly. If you logged in the desktop, the installation will finally return with an error like this:

Enter CUDA Samples Location [ default is /home/jacky ]:
Installing the NVIDIA display driver…
It appears that an X server is running. Please exit X before installation. If you’re sure that X is not running, but are getting this error, please delete any X lock files in /tmp.

===========
= Summary =
===========

Driver:   Installation Failed
Toolkit:  Installation skipped
Samples:  Installation skipped

Logfile is /tmp/cuda_install_10084.log

Tried the following these steps to fix it:

a. Exit x-window by using short key Ctrl+Alt+F1
b. Login in terminal and stop x-window by service lightdm stop.
c. Start install CUDA 7.0 ToolKit.
If the installation wizard tells you reboot, just do it. And you’ll finally get a successful installation.
d. Reboot Ubuntu after finished, and login Ubuntu with x-window.

Installing the NVIDIA display driver…
Installing the CUDA Toolkit in /usr/local/cuda-7.0 …
Missing recommended library: libGLU.so
Missing recommended library: libXi.so
Missing recommended library: libXmu.so

Installing the CUDA Samples in /home/jacky …
Copying samples to /home/jacky/NVIDIA_CUDA-7.0_Samples now…
Finished copying samples.

===========
= Summary =
===========

Driver:   Installed
Toolkit:  Installed in /usr/local/cuda-7.0
Samples:  Installed in /home/jacky, but missing recommended libraries

Please make sure that
–   PATH includes /usr/local/cuda-7.0/bin
–   LD_LIBRARY_PATH includes /usr/local/cuda-7.0/lib64, or, add /usr/local/cuda-7.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-7.0/bin
To uninstall the NVIDIA Driver, run nvidia-uninstall

Please see CUDA_Getting_Started_Guide_For_Linux.pdf in /usr/local/cuda-7.0/doc/pdf for detailed information on setting up CUDA.

Logfile is /tmp/cuda_install_2719.log

To fix the missing recommended libraries warning, just:

Run the installation again, everything was OK.

3. Try verify the installation with a simple test program

Name it with test_cuda.c, and compile it with command:

If return with success, means the installation was OK.

4. Try run x264

The encoding was started with OpenCL enabled.

Leave a comment

Your email address will not be published. Required fields are marked *