矩池云上nvidia opencl安装及测试教程
IPFS
![](https://assets.matters.news/embed/8a663ee0-2ccd-4d9c-b87b-75e16636435f.png)
本教程租用的是2080ti,3.7多框架镜像。
添加nvidia-cuda的阿里源
![](https://assets.matters.news/embed/84be341e-e693-4854-8b74-723b528e9f6c.png)
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
![](https://assets.matters.news/embed/ddb60688-91ee-4817-bca1-400de0b78d03.png)
apt search nvidia-opencl
![](https://assets.matters.news/embed/0f16fbeb-3ce6-475e-b631-56e779b22dd9.png)
apt-get install nvidia-opencl-dev
创建链接
mkdir -p /etc/OpenCL/vendors/ cd /etc/OpenCL/vendors ls
![](https://assets.matters.news/embed/ce4ac91c-e407-4bcd-8f94-4b4f58cefc0d.png)
vim nvidia.icd
在nvidia.icd填入以下链接
/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1
![](https://assets.matters.news/embed/96fc85c8-7a4f-4db2-8259-a4827cc7d957.png)
验证释放正确链接
cat nvidia.icd ll /usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1
![](https://assets.matters.news/embed/dbe00666-4817-41a6-9bb1-35b373abbb4c.png)
测试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
![](https://assets.matters.news/embed/89e17a54-9350-4431-8310-52e1e659c0b0.png)
出现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)
喜欢我的作品吗?别忘了给予支持与赞赏,让我知道在创作的路上有你陪伴,一起延续这份热忱!
![](https://imagedelivery.net/kDRCweMmqLnTPNlbum-pYA/prod/avatar/49c9021f-4678-4410-a958-c3d7eb7f5db6.png/public)
- 来自作者
- 相关推荐