矩池云上nvidia opencl安装及测试教程
本教程租用的是2080ti,3.7多框架镜像。
添加nvidia-cuda的阿里源
curl -fsSL https://mirrors.aliyun.com/nvidia-cuda/ubuntu1804/x86_64/7fa2af80.pub | apt-key add - echo "deb https://mirrors.aliyun.com/nvidia-cuda/ubuntu1804/x86_64/ /" > /etc/apt/sources.list.d/cuda.list apt update
安装nvidia opencl
apt search nvidia-opencl
apt-get install nvidia-opencl-dev
创建链接
mkdir -p /etc/OpenCL/vendors/ cd /etc/OpenCL/vendors ls
vim nvidia.icd
在nvidia.icd填入以下链接
/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1
验证释放正确链接
cat nvidia.icd ll /usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1
测试opencl
clGetPlatformIDs.c 内容
#include <stdio.h> #include <CL/opencl.h> int main(int argc, char **argv) { int status; cl_uint n_platform; status = clGetPlatformIDs(0, NULL, &n_platform); if(status != CL_SUCCESS) { fprintf(stderr, "no platforms %d\n", status); return -1; } else { fprintf(stderr, "number of CL platforms %d\n", n_platform); return 0; } }
进入解决,我这里的文件夹是22,大家按照自己习惯来即可
cd /22 ls gcc clGetPlatformIDs.c -lOpenCL -o main chmod +x main ./main
出现number of CL platforms 1,安装及测试就完成了
参考文章
Install OpenCL on Ubuntu 14.04 and Nvidia
Ubuntu 18.10 with Nvidia 410: OpenCL not working anymore (clinfo: 0 platforms)
Opencl clGetPlatformIDs error -1001
OpenCL crashes on call to clGetPlatformIDs
ERROR: clGetPlatformIDs -1001 when running OpenCL code (Linux)