针对Ubuntu 不同版本Ubuntu 20.04和Ubuntu 16.04对集成显卡安装opencl说明.
1、安装支持opencl显卡驱动
1)Ubuntu 20.04
sudo apt-get update
sudo apt-get update && sudo apt-get install -y --no-install-recommends curl gpg gpg-agent && sudo curl https://repositories.intel.com/graphics/intel-graphics.key | sudo gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg && echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/graphics/ubuntu focal-legacy main' | sudo tee /etc/apt/sources.list.d/intel.gpu.focal.list
2) Ubuntu 16.04
通过intel-graphics-update-tool进行安装,先安装 intel-graphics-update-tool ,再安装显卡驱动(参考https://cloud.tencent.com/developer/article/1386851?from=15425)
wget https://download.01.org/gfx/ubuntu/16.04/main/pool/main/i/intel-graphics-update-tool/intel-graphics-update-tool_2.0.2_amd64.deb
sudo dpkg -i intel-graphics-update-tool_2.0.2_amd64.deb
sudo intel-graphics-update-tool
sudo apt-get install -f
sudo intel-graphics-update-tool
wget $(echo "https://download".01.org/gfx/RPM-GPG-GROUP-KEY-ilg) -O - | sudo apt-key add -
sudo apt-get update
2、根据opencl驱动
1)Ubuntu 20.04
sudo apt-get update
sudo apt-get install -y --no-install-recommends intel-opencl-icd intel-level-zero-gpu level-zero
2)Ubuntu 16.04
https://blog.csdn.net/GerZhouGengCheng/article/details/121358166
下载deb安装包
cd opencl
wget https://github.com/intel/compute-runtime/releases/download/18.45.11804/intel-gmmlib_18.4.0.348_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/18.45.11804/intel-igc-core_18.44.1060_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/18.45.11804/intel-igc-opencl_18.44.1060_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/18.45.11804/intel-opencl_18.45.11804_amd64.deb
以root权限安装deb包
sudo dpkg -i *.deb
3、安装clinfo进行确认OpenCL驱动信息
1)安装clinfo
sudo apt-get install clinfo
2)查看Intel GPU OpenCL驱动信息
sudo clinfo
4、根据opencl开发库
sudo apt-get install opencl-headers ocl-icd-opencl-dev
5、opencl测试
测试代码(矩阵乘法):cl.c、matecv.cl
编译:
gcc cl.c -o opencl_t -g -lOpenCL
运行:
./opencl_t
6、GPU的监控工具是intel-gpu-tools
安装后使用sudo intel-gpu-tools就可以监控gpu的使用率。安装完毕后,
系统中会多种三个gpu工具: intel_gpu_abrt intel_gpu_time intel_gpu_top
其中,常用的是intel_gpu_top和intel_gpu_time
安装命令:
apt-get install intel-gpu-tools
查看GPU使用情况命令:
sudo intel_gpu_top
参考
https://cloud.tencent.com/developer/article/1386851?from=15425