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 Intel® Graphics Compute Runtime for OpenCL™ Driver on Linux.
20 # Usage: sudo -E ./install_NEO_OCL_driver.sh
22 # Supported platforms:
23 # 6th-11th generation Intel® Core™ 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'
34 AVAILABLE_DRIVERS=("19.41.14441" "20.35.17767")
40 usage="Usage: $(basename "$0") [OPTIONS]...
41 Download and installs the Intel® Graphics Compute Runtime for OpenCL™ Driver on Linux
44 -y Replace the currently installed driver with the newer version.
45 -d, --install_driver Manually select driver version to one of available to install drivers.
46 Default value: $INSTALL_DRIVER_VERSION
47 Available to install drivers: ${AVAILABLE_DRIVERS[*]}
48 -h, --help display this help and exit"
57 user_chosen_driver="$2"
58 if [[ " ${AVAILABLE_DRIVERS[@]} " =~ " ${user_chosen_driver} " ]]; then
59 INSTALL_DRIVER_VERSION=$user_chosen_driver
61 echo "ERROR: unable to install the driver ${user_chosen_driver}."
62 echo "Available values: ${AVAILABLE_DRIVERS[*]}"
77 echo "$(basename "$0"): invalid option -- '${key}'"
78 echo "Try '$(basename "$0") --help' for more information."
83 _install_prerequisites_centos()
85 # yum doesn't accept timeout in seconds as parameter
87 echo "Note: if yum becomes non-responsive, try aborting the script and run:"
91 CMDS=("yum -y install numactl-libs numactl ocl-icd ocl-icd-devel")
93 for cmd in "${CMDS[@]}"; do
96 if [[ $? -ne 0 ]]; then
97 echo "ERROR: failed to run $cmd" >&2
98 echo "Problem (or disk space)?" >&2
99 echo ". Verify that you have enough disk space, and run the script again." >&2
106 _install_prerequisites_ubuntu()
108 CMDS=("apt-get -y update"
109 "apt-get -y install libnuma1 ocl-icd-libopencl1")
111 for cmd in "${CMDS[@]}"; do
114 if [[ $? -ne 0 ]]; then
115 echo "ERROR: failed to run $cmd" >&2
116 echo "Problem (or disk space)?" >&2
117 echo " sudo -E $0" >&2
118 echo "2. Verify that you have enough disk space, and run the script again." >&2
124 install_prerequisites()
126 if [[ $DISTRO == "centos" ]]; then
127 echo "Installing prerequisites..."
128 _install_prerequisites_centos
129 elif [[ $DISTRO == "ubuntu" ]]; then
130 echo "Installing prerequisites..."
131 _install_prerequisites_ubuntu
139 # On a CentOS 7.2 machine with Intel Parallel Composer XE 2017
140 # installed we got conflicts when trying to deploy these rpms.
141 # If that happens to you too, try again with:
142 # IGFX_RPM_FLAGS="--force" sudo -E ./install_NEO_OCL_driver.sh install
144 cmd="rpm $IGFX_RPM_FLAGS -ivh --nodeps --force $1"
156 _install_user_mode_centos()
158 _deploy_rpm "intel*.rpm"
159 if [[ $? -ne 0 ]]; then
160 echo "ERROR: failed to install rpms $cmd error" >&2
161 echo "Make sure you have enough disk space or fix the problem manually and try again." >&2
166 _install_user_mode_ubuntu()
168 _deploy_deb "intel*.deb"
169 if [[ $? -ne 0 ]]; then
170 echo "ERROR: failed to install rpms $cmd error" >&2
171 echo "Make sure you have enough disk space or fix the problem manually and try again." >&2
179 echo "Installing user mode driver..."
181 if [[ $DISTRO == "centos" ]]; then
182 _install_user_mode_centos
184 _install_user_mode_ubuntu
186 # exit from $SCRIPT_DIR/neo folder
189 rm -rf "$SCRIPT_DIR/neo"
192 _uninstall_user_mode_centos()
194 echo Looking for previously installed user-mode driver...
195 PACKAGES=("intel-opencl"
200 for package in "${PACKAGES[@]}"; do
201 echo "rpm -qa | grep $package"
202 found_package=$(rpm -qa | grep "$package")
203 if [[ $? -eq 0 ]]; then
204 echo "Found installed user-mode driver, performing uninstall..."
205 cmd="rpm -e --nodeps ${found_package}"
208 if [[ $? -ne 0 ]]; then
209 echo "ERROR: failed to uninstall existing user-mode driver." >&2
210 echo "Please try again manually and run the script again." >&2
217 _uninstall_user_mode_ubuntu()
219 echo Looking for previously installed user-mode driver...
221 PACKAGES=("intel-opencl"
227 for package in "${PACKAGES[@]}"; do
228 found_package=$(dpkg-query -W -f='${binary:Package}\n' "${package}")
229 if [[ $? -eq 0 ]]; then
230 echo "Found installed user-mode driver, performing uninstall..."
231 cmd="apt-get autoremove -y $package"
234 if [[ $? -ne 0 ]]; then
235 echo "ERROR: failed to uninstall existing user-mode driver." >&2
236 echo "Please try again manually and run the script again." >&2
243 uninstall_user_mode()
245 if [[ $DISTRO == "centos" ]]; then
246 _uninstall_user_mode_centos
248 _uninstall_user_mode_ubuntu
252 _is_package_installed()
254 if [[ $DISTRO == "centos" ]]; then
255 cmd="rpm -qa | grep $1"
257 cmd="dpkg-query -W -f='${binary:Package}\n' $pkg"
264 _download_packages_ubuntu()
266 case $INSTALL_DRIVER_VERSION in
268 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-gmmlib_19.3.2_amd64.deb
269 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-igc-core_1.0.2597_amd64.deb
270 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-igc-opencl_1.0.2597_amd64.deb
271 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-opencl_19.41.14441_amd64.deb
272 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-ocloc_19.41.14441_amd64.deb
275 wget https://github.com/intel/compute-runtime/releases/download/20.35.17767/intel-gmmlib_20.2.4_amd64.deb
276 wget https://github.com/intel/compute-runtime/releases/download/20.35.17767/intel-igc-core_1.0.4756_amd64.deb
277 wget https://github.com/intel/compute-runtime/releases/download/20.35.17767/intel-igc-opencl_1.0.4756_amd64.deb
278 wget https://github.com/intel/compute-runtime/releases/download/20.35.17767/intel-opencl_20.35.17767_amd64.deb
279 wget https://github.com/intel/compute-runtime/releases/download/20.35.17767/intel-ocloc_20.35.17767_amd64.deb
280 wget https://github.com/intel/compute-runtime/releases/download/20.35.17767/intel-level-zero-gpu_1.0.17767_amd64.deb
283 echo "ERROR: Unrecognized driver ${INSTALL_DRIVER_VERSION}."
284 echo "Available values: ${AVAILABLE_DRIVERS[@]}"
289 _download_packages_centos()
292 case $INSTALL_DRIVER_VERSION in
294 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
295 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
296 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
297 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
298 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
299 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
302 wget -O intel-opencl-20.35.17767-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/20.35.17767/centos-7/intel-opencl-20.35.17767-1.el7.x86_64.rpm/download
303 wget -O level-zero-1.0.0-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/20.35.17767/centos-7/level-zero-1.0.0-1.el7.x86_64.rpm/download
304 wget -O level-zero-devel-1.0.0-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/20.35.17767/centos-7/level-zero-devel-1.0.0-1.el7.x86_64.rpm/download
305 wget -O intel-igc-opencl-1.0.4756-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/20.35.17767/centos-7/intel-igc-opencl-1.0.4756-1.el7.x86_64.rpm/download
306 wget -O intel-igc-opencl-devel-1.0.4756-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/20.35.17767/centos-7/intel-igc-opencl-devel-1.0.4756-1.el7.x86_64.rpm/download
307 wget -O intel-igc-core-1.0.4756-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/20.35.17767/centos-7/intel-igc-core-1.0.4756-1.el7.x86_64.rpm/download
308 wget -O intel-gmmlib-20.2.4-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/20.35.17767/centos-7/intel-gmmlib-20.2.4-1.el7.x86_64.rpm/download
309 wget -O intel-gmmlib-devel-20.2.4-1.el7.x86_64.rpm https://sourceforge.net/projects/intel-compute-runtime/files/20.35.17767/centos-7/intel-gmmlib-devel-20.2.4-1.el7.x86_64.rpm/download
312 echo "ERROR: Unrecognized driver ${INSTALL_DRIVER_VERSION}."
313 echo "Available values: ${AVAILABLE_DRIVERS[@]}"
319 _verify_checksum_ubuntu()
321 case $INSTALL_DRIVER_VERSION in
323 wget https://github.com/intel/compute-runtime/releases/download/19.41.14441/ww41.sum
324 sha256sum -c ww41.sum
327 wget https://github.com/intel/compute-runtime/releases/download/20.35.17767/ww35.sum
328 sha256sum -c ww35.sum
331 echo "ERROR: Unrecognized driver ${INSTALL_DRIVER_VERSION}."
332 echo "Available values: ${AVAILABLE_DRIVERS[@]}"
337 _verify_checksum_centos()
339 case $INSTALL_DRIVER_VERSION in
341 sha1sum -c "$SCRIPT_DIR/neo_centos_19.41.14441.sum"
344 sha1sum -c "$SCRIPT_DIR/neo_centos_20.35.17767.sum"
347 echo "ERROR: Unrecognized driver ${INSTALL_DRIVER_VERSION}."
348 echo "Available values: ${AVAILABLE_DRIVERS[@]}"
355 if [[ $DISTRO == "centos" ]]; then
356 _verify_checksum_centos
358 _verify_checksum_ubuntu
364 mkdir -p "$SCRIPT_DIR/neo"
367 if [[ $DISTRO == "centos" ]]; then
368 _download_packages_centos
370 _download_packages_ubuntu
373 if [[ $? -ne 0 ]]; then
374 echo "ERROR: checksums do not match for the downloaded packages"
375 echo " Please verify your Internet connection and make sure you have enough disk space or fix the problem manually and try again. "
382 # check if first version is greater than second version
383 test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
389 echo "Installation completed successfully."
392 echo "Add OpenCL users to the video and render group: 'sudo usermod -a -G video,render USERNAME'"
393 echo " e.g. if the user running OpenCL host applications is foo, run: sudo usermod -a -G video,render foo"
394 echo " Current user has been already added to the video and render group"
397 echo "If you use 8th Generation Intel® Core™ processor, add:"
398 echo " i915.alpha_support=1"
399 echo " to the 4.14 kernel command line, in order to enable OpenCL functionality for this platform."
406 if [[ $EUID -ne 0 ]]; then
407 echo "ERROR: you must run this script as root." >&2
408 echo "Please try again with \"sudo -E $0\", or as root." >&2
413 add_user_to_video_group()
415 local real_user=$(logname 2>/dev/null || echo "${SUDO_USER:-${USER}}")
417 echo "Adding $real_user to the video group..."
418 usermod -a -G video "$real_user"
419 if [[ $? -ne 0 ]]; then
420 echo "WARNING: unable to add $real_user to the video group" >&2
422 echo "Adding $real_user to the render group..."
423 usermod -a -G render "$real_user"
424 if [[ $? -ne 0 ]]; then
425 echo "WARNING: unable to add $real_user to the render group" >&2
429 _check_distro_version()
431 if [[ $DISTRO == centos ]]; then
432 CENTOS_MINOR=$(sed 's/CentOS Linux release 7\.\([[:digit:]]\+\).\+/\1/' /etc/centos-release)
433 if [[ $? -ne 0 ]]; then
434 echo "ERROR: failed to obtain CentOS version minor." >&2
435 echo "This script is supported only on CentOS 7 and above." >&2
438 elif [[ $DISTRO == ubuntu ]]; then
439 UBUNTU_VERSION=$(grep -m1 'VERSION_ID' /etc/os-release | grep -Eo "[0-9]{2}.[0-9]{2}")
440 if [[ $UBUNTU_VERSION != '18.04' && $UBUNTU_VERSION != '20.04' ]]; then
441 echo "Warning: This runtime can be installed only on Ubuntu 18.04 or Ubuntu 20.04."
442 echo "More info https://github.com/intel/compute-runtime/releases" >&2
443 echo "Installation of Intel Compute Runtime interrupted"
451 if [[ -f /etc/centos-release ]]; then
453 elif [[ -f /etc/lsb-release ]]; then
457 _check_distro_version
462 if [ "$agreement" == true ]; then
466 echo "This script will download and install Intel(R) Graphics Compute Runtime $INSTALL_DRIVER_VERSION, "
467 echo "that was used to validate this OpenVINO™ package."
468 echo "In case if you already have the driver - script will try to remove it."
470 read -p "Want to proceed? (y/n): " yn
478 check_specific_generation()
480 echo "Checking processor generation..."
481 specific_generation=$(grep -m1 'model name' /proc/cpuinfo | grep -E "i[357]-1[01][0-9]{2,4}N?G[147R]E?")
482 if [[ ! -z "$specific_generation" && "$INSTALL_DRIVER_VERSION" != '20.35.17767' ]]; then
483 echo "$(basename "$0"): Detected 10th generation Intel® Core™ processor (formerly Ice Lake) or 11th generation Intel® Core™ processor (formerly Tiger Lake)."
484 echo "Driver version 20.35.17767 is going to be installed to fully utilize hardware features and performance."
486 read -p "You are still able to use the older version 19.41.14441. Use the older driver? (y/n) [n] " yn
490 [Nn]*) INSTALL_DRIVER_VERSION='20.35.17767' && return 0 ;;
496 check_current_driver()
498 echo "Checking current driver version..."
499 if [[ $DISTRO == centos ]]; then
500 gfx_version=$(yum info intel-opencl | grep Version)
501 elif [[ $DISTRO == ubuntu ]]; then
502 gfx_version=$(apt show intel-opencl | grep Version)
505 gfx_version="$(echo -e "${gfx_version}" | sed -e 's/^Version[[:space:]]*\:[[:space:]]*//')"
506 check_specific_generation
508 # install NEO OCL driver if the current driver version < INSTALL_DRIVER_VERSION
509 if [[ ! -z $gfx_version && "$(printf '%s\n' "$INSTALL_DRIVER_VERSION" "$gfx_version" | sort -V | head -n 1)" = "$INSTALL_DRIVER_VERSION" ]]; then
510 echo "Intel® Graphics Compute Runtime for OpenCL™ Driver installation skipped because current version greater or equal to $INSTALL_DRIVER_VERSION" >&2
511 echo "Installation of Intel® Graphics Compute Runtime for OpenCL™ Driver interrupted." >&2
514 echo "Starting installation..."
521 install_prerequisites
524 add_user_to_video_group
529 echo "Intel® Graphics Compute Runtime for OpenCL™ Driver installer"
538 [[ "$0" == "$BASH_SOURCE" ]] && main "$@"