3 # Copyright (c) 2018 - 2020 Intel Corporation
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # Installs the Graphics Driver for OpenCL on Linux.
20 # Usage: sudo -E ./install_NEO_OCL_driver.sh
22 # Supported platforms:
23 # 6th, 7th, 8th or 9th generation Intel® processor with Intel(R)
24 # Processor Graphics Technology not previously disabled by the BIOS
25 # or motherboard settings
32 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
33 INSTALL_DRIVER_VERSION='19.41.14441'
37 _install_prerequisites_centos()
39 # yum doesn't accept timeout in seconds as parameter
41 echo "Note: if yum becomes non-responsive, try aborting the script and run:"
45 CMDS=("yum -y install tar libpciaccess numactl-libs"
46 "yum -y groupinstall 'Development Tools'"
47 "yum -y install rpmdevtools openssl openssl-devel bc numactl ocl-icd ocl-icd-devel")
49 for cmd in "${CMDS[@]}"; do
52 if [[ $? -ne 0 ]]; then
53 echo ERROR: failed to run $cmd >&2
54 echo Problem \(or disk space\)? >&2
55 echo . Verify that you have enough disk space, and run the script again. >&2
62 _install_prerequisites_ubuntu()
64 CMDS=("apt-get -y update"
65 "apt-get -y install libnuma1 ocl-icd-libopencl1")
67 for cmd in "${CMDS[@]}"; do
70 if [[ $? -ne 0 ]]; then
71 echo ERROR: failed to run $cmd >&2
72 echo Problem \(or disk space\)? >&2
73 echo " sudo -E $0" >&2
74 echo 2. Verify that you have enough disk space, and run the script again. >&2
80 install_prerequisites()
82 if [[ $DISTRO == "centos" ]]; then
83 echo Installing prerequisites...
84 _install_prerequisites_centos
85 elif [[ $DISTRO == "ubuntu" ]]; then
86 echo Installing prerequisites...
87 _install_prerequisites_ubuntu
95 # On a CentOS 7.2 machine with Intel Parallel Composer XE 2017
96 # installed we got conflicts when trying to deploy these rpms.
97 # If that happens to you too, try again with:
98 # IGFX_RPM_FLAGS="--force" sudo -E ./install_NEO_OCL_driver.sh install
100 cmd="rpm $IGFX_RPM_FLAGS -ivh --nodeps --force $1"
113 _install_user_mode_centos()
115 _deploy_rpm "intel*.rpm"
116 if [[ $? -ne 0 ]]; then
117 echo ERROR: failed to install rpms $cmd error >&2
118 echo Make sure you have enough disk space or fix the problem manually and try again. >&2
123 _install_user_mode_ubuntu()
125 _deploy_deb "intel*.deb"
126 if [[ $? -ne 0 ]]; then
127 echo ERROR: failed to install rpms $cmd error >&2
128 echo Make sure you have enough disk space or fix the problem manually and try again. >&2
136 echo "Installing user mode driver..."
138 if [[ $DISTRO == "centos" ]]; then
139 _install_user_mode_centos
141 _install_user_mode_ubuntu
143 # exit from $SCRIPT_DIR/neo folder
146 rm -rf $SCRIPT_DIR/neo
149 _uninstall_user_mode_centos()
151 echo Looking for previously installed user-mode driver...
152 PACKAGES=("intel-opencl"
157 for package in "${PACKAGES[@]}"; do
158 echo "rpm -qa | grep $package"
159 found_package=$(rpm -qa | grep $package)
160 if [[ $? -eq 0 ]]; then
161 echo Found installed user-mode driver, performing uninstall...
162 cmd="rpm -e --nodeps ${found_package}"
165 if [[ $? -ne 0 ]]; then
166 echo ERROR: failed to uninstall existing user-mode driver. >&2
167 echo Please try again manually and run the script again. >&2
174 _uninstall_user_mode_ubuntu()
176 echo Looking for previously installed user-mode driver...
178 PACKAGES=("intel-opencl"
184 for package in "${PACKAGES[@]}"; do
185 apt remove -y $package
186 if [[ $? -ne 0 ]]; then
187 echo ERROR: failed to uninstall existing user-mode driver. >&2
188 echo Please try again manually and run the script again. >&2
194 uninstall_user_mode()
196 if [[ $DISTRO == "centos" ]]; then
197 _uninstall_user_mode_centos
199 _uninstall_user_mode_ubuntu
203 _is_package_installed()
205 if [[ $DISTRO == "centos" ]]; then
206 cmd="rpm -qa | grep $1"
208 cmd="dpkg-query -W -f='${binary:Package}\n' $pkg"
215 _download_packages_ubuntu()
217 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-gmmlib_19.3.2_amd64.deb
218 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-igc-core_1.0.2597_amd64.deb
219 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-igc-opencl_1.0.2597_amd64.deb
220 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-opencl_19.41.14441_amd64.deb
221 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-ocloc_19.41.14441_amd64.deb
224 _download_packages_centos()
226 wget -O intel-igc-core-1.0.2597-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/19.41.14441/centos-7/intel-igc-core-1.0.2597-1.el7.x86_64.rpm/download
227 wget -O intel-opencl-19.41.14441-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/19.41.14441/centos-7/intel-opencl-19.41.14441-1.el7.x86_64.rpm/download
228 wget -O intel-igc-opencl-devel-1.0.2597-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/19.41.14441/centos-7/intel-igc-opencl-devel-1.0.2597-1.el7.x86_64.rpm/download
229 wget -O intel-igc-opencl-1.0.2597-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/19.41.14441/centos-7/intel-igc-opencl-1.0.2597-1.el7.x86_64.rpm/download
230 wget -O intel-gmmlib-19.3.2-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/19.41.14441/centos-7/intel-gmmlib-19.3.2-1.el7.x86_64.rpm/download
231 wget -O intel-gmmlib-devel-19.3.2-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/19.41.14441/centos-7/intel-gmmlib-devel-19.3.2-1.el7.x86_64.rpm/download
235 _verify_checksum_ubuntu()
237 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/ww41.sum
238 sha256sum -c ww41.sum
241 _verify_checksum_centos()
243 sha1sum -c $SCRIPT_DIR/neo_centos_ww41.sum
248 if [[ $DISTRO == "centos" ]]; then
249 _verify_checksum_centos
251 _verify_checksum_ubuntu
257 mkdir -p $SCRIPT_DIR/neo
260 if [[ $DISTRO == "centos" ]]; then
261 _download_packages_centos
263 _download_packages_ubuntu
266 if [[ $? -ne 0 ]]; then
267 echo "ERROR: checksum do not match for downloaded packages"
268 echo " Please verify your Internet connection and make sure you have enough disk space or fix the problem manually and try again "
275 # check if first version is greater than second version
276 test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
281 kernel_version=$(uname -r)
284 echo Installation completed successfully.
287 echo "Add OpenCL users to the video group: 'sudo usermod -a -G video USERNAME'"
288 echo " e.g. if the user running OpenCL host applications is foo, run: sudo usermod -a -G video foo"
289 echo " Current user has been already added to the video group"
292 # ask to install kernel 4.14 if current kernel version < 4.13 (GPU NEO driver supports only kernels 4.13.x and higher)
293 if version_gt "4.13" "$kernel_version" ; then
294 echo "Install 4.14 kernel using install_4_14_kernel.sh script and reboot into this kernel"
298 echo "If you use 8th Generation Intel® Core™ processor, you will need to add:"
299 echo " i915.alpha_support=1"
300 echo " to the 4.14 kernel command line, in order to enable OpenCL functionality for this platform."
307 if [[ $EUID -ne 0 ]]; then
308 echo "ERROR: you must run this script as root." >&2
309 echo "Please try again with "sudo -E $0", or as root." >&2
314 add_user_to_video_group()
316 local real_user=$(logname 2>/dev/null || echo ${SUDO_USER:-${USER}})
318 echo Adding $real_user to the video group...
319 usermod -a -G video $real_user
320 if [[ $? -ne 0 ]]; then
321 echo WARNING: unable to add $real_user to the video group >&2
325 _check_distro_version()
327 if [[ $DISTRO == centos ]]; then
328 CENTOS_MINOR=$(sed 's/CentOS Linux release 7\.\([[:digit:]]\+\).\+/\1/' /etc/centos-release)
329 if [[ $? -ne 0 ]]; then
330 echo ERROR: failed to obtain CentOS version minor. >&2
331 echo This script is supported only on CentOS 7 and above. >&2
334 elif [[ $DISTRO == ubuntu ]]; then
335 UBUNTU_VERSION=$(lsb_release -r -s)
336 if [[ $UBUNTU_VERSION != '18.04' && $UBUNTU_VERSION != '20.04' ]]; then
337 echo "Warning: This runtime can be installed only on Ubuntu 18.04 or Ubuntu 20.04."
338 echo "More info https://github.com/intel/compute-runtime/releases" >&2
339 echo "Installation of Intel Compute Runtime interrupted"
347 if [[ -f /etc/centos-release ]]; then
349 elif [[ -f /etc/lsb-release ]]; then
353 _check_distro_version
358 if [ "$params" == "-y" ]; then
362 echo "This script will download and install Intel(R) Graphics Compute Runtime $INSTALL_DRIVER_VERSION, "
363 echo "that was used to validate this OpenVINO package."
364 echo "In case if you already have the driver - script will try to remove it."
366 read -p "Want to proceed? (y/n): " yn
374 check_current_driver()
376 echo "Checking current driver version..."
377 if [[ $DISTRO == centos ]]; then
378 gfx_version=$(yum info intel-opencl | grep Version)
379 elif [[ $DISTRO == ubuntu ]]; then
380 gfx_version=$(apt show intel-opencl | grep Version)
382 gfx_version="$(echo -e "${gfx_version}" | sed -e 's/^Version\:[[:space:]]*//')"
383 # install NEO OCL driver if current driver version < 19.41.14441
384 if [[ ! -z $gfx_version && "$(printf '%s\n' "$INSTALL_DRIVER_VERSION" "$gfx_version" | sort -V | head -n 1)" = "$INSTALL_DRIVER_VERSION" ]]; then
385 echo "Intel(R) Graphics Compute Runtime installation skipped because current version greater or equal to $INSTALL_DRIVER_VERSION" >&2
386 echo "Installation of Intel Compute Runtime interrupted" >&2
389 echo "Starting installation"
396 install_prerequisites
399 add_user_to_video_group
404 echo "Intel OpenCL graphics driver installer"
413 [[ "$0" == "$BASH_SOURCE" ]] && main "$@"