首先参考如下文章部署CUDA开发环境

FairMOT部署 Cuda环境搭建并进行推理验证_tugouxp的专栏-CSDN博客环境准备1.PC Host Ubuntu 18.04.6,Linux Kernel 5.4,内核版本关系不大,记录下来备查。2.安装基础工具,比如GCC,CMAKE,VIM,GIT等等,工具尽量完备, 如果做不到,遇到问题临时下载也可。3.安装python3发行版,我用的是anaconda发行版,具体版本是 Anaconda3-2020.11-Linux-x86_64.sh下载地址在如下链接,选择对应的版本即可。https://repo.anaco...https://blog.csdn.net/tugouxp/article/details/121248457Darknet环境安装CUDANN实现推理加速_tugouxp的专栏-CSDN博客首先参考下面几篇文章安装darknet,cuda的基础环境:Yolov3网络的物体检测_tugouxp的专栏-CSDN博客1.Get darknet 代码$ git clone https://github.com/pjreddie/darknet$ cd darknet$ makecaozilong@caozilong-Vostro-3268:~/yolo$ git clone https://github.com/pjreddie/darknet正克隆到 'darknet'...remote: Enhttps://blog.csdn.net/tugouxp/article/details/121306727之后,执行

locate libOpenCL.so

命令,有如下输出,说明OpenCL和CUDA环境是一起安装的,所以安装环境时并没有特意为OpenCL去做什么,CUDA环境OK了,OPENCL的环境自然就OK了。

网上白嫖的一份OpenCL源码:

#include <stdio.h>
#include <stdlib.h>
#include <alloca.h>
#include <CL/cl.h>void displayPlatformInfo(cl_platform_id id,cl_platform_info param_name,const char* paramNameAsStr) {cl_int error = 0;size_t paramSize = 0;error = clGetPlatformInfo( id, param_name, 0, NULL, &paramSize );char* moreInfo = (char*)alloca( sizeof(char) * paramSize);error = clGetPlatformInfo( id, param_name, paramSize, moreInfo, NULL );if (error != CL_SUCCESS ) {perror("Unable to find any OpenCL platform information");return;}printf("%s: %s\n", paramNameAsStr, moreInfo);
}int main() {/* OpenCL 1.1 data structures */cl_platform_id* platforms;/* OpenCL 1.1 scalar data types */cl_uint numOfPlatforms;cl_int  error;/* Get the number of platforms Remember that for each vendor's SDK installed on the computer,the number of available platform also increased. */error = clGetPlatformIDs(0, NULL, &numOfPlatforms);if(error != CL_SUCCESS) {           perror("Unable to find any OpenCL platforms");exit(1);}// Allocate memory for the number of installed platforms.// alloca(...) occupies some stack space but is automatically freed on returnplatforms = (cl_platform_id*) alloca(sizeof(cl_platform_id) * numOfPlatforms);printf("Number of OpenCL platforms found: %d\n", numOfPlatforms);error = clGetPlatformIDs(numOfPlatforms, platforms, NULL);if(error != CL_SUCCESS) {          perror("Unable to find any OpenCL platforms");exit(1);}// We invoke the API 'clPlatformInfo' twice for each parameter we're trying to extract// and we use the return value to create temporary data structures (on the stack) to store// the returned information on the second invocation.for(cl_uint i = 0; i < numOfPlatforms; ++i) {displayPlatformInfo( platforms[i], CL_PLATFORM_PROFILE, "CL_PLATFORM_PROFILE" );displayPlatformInfo( platforms[i], CL_PLATFORM_VERSION, "CL_PLATFORM_VERSION" );displayPlatformInfo( platforms[i], CL_PLATFORM_NAME,    "CL_PLATFORM_NAME" );displayPlatformInfo( platforms[i], CL_PLATFORM_VENDOR,  "CL_PLATFORM_VENDOR" );displayPlatformInfo( platforms[i], CL_PLATFORM_EXTENSIONS, "CL_PLATFORM_EXTENSIONS" );}return 0;
}

编译:

gcc -I/usr/local/cuda-11.5/targets/x86_64-linux/include main.c -o main -L/usr/local/cuda-11.5/targets/x86_64-linux/lib/ -lOpenCL

看一下库中所有的以cl打头的API有哪些?

现在来看,与其说OpenCL是一种语言,不如说它是一种API,类似于openGL,openvx一样,是API层面的意思,并非编程语言层面的意义,openCL也是用C语言编程,并且用GCC编译的不是么 ?:)

这种理解有错误,具体原因可以看这篇博客,OpenCL是有独立的语言文件的。

OpenCL编程之二_tugouxp的专栏-CSDN博客白嫖来的C端代码:matrix.c:#include <stdio.h>#include <stdlib.h>#include <alloca.h>#include <CL/cl.h>#pragma warning( disable : 4996 )int main() {cl_int error;cl_platform_id platforms;cl_device_id devices;cl_context contehttps://blog.csdn.net/tugouxp/article/details/121844159


结束

OpenCL编程初探相关推荐

  1. OpenCL编程详细解析与实例

    OpenCL编程详细解析与实例 C语言与OpenCL的编程示例比较 参考链接: https://www.zhihu.com/people/wujianming_110117/posts 先以图像旋转的 ...

  2. AMD院士站台 异构计算与OpenCL编程师资培训首站清华开讲

    摘要:2013年10月14日,"2013年异构计算与OpenCL编程师资培训"在清华大学召开.本活动邀请到AMD.Khronos Group及清华大学的多位并行计算领域专家,与参会 ...

  3. 机器学习与计算机视觉(opencl编程)

    [ 声明:版权所有,欢迎转载,请勿用于商业用途.  联系信箱:feixiaoxing @163.com] 因为学习cuda的原因,所以最近一段时间对GPU编程比较感兴趣.大家都知道,cuda是属于nv ...

  4. OpenCL Programming Guide - OpenCL 编程指南 - 书中源代码

    OpenCL Programming Guide - OpenCL 编程指南 - 书中源代码 1. Heterogeneous Compute http://www.heterogeneouscomp ...

  5. 小丸子函数式编程初探

    小丸子函数式编程初探 小丸子函数式编程初探 question 函数式编程 命令式编程 vs 函数式编程 高阶函数 实用小栗子 1. question 前一个项目,顺利完成的时候感觉特别棒.但是后面需求 ...

  6. Opencl编程的标准开发流程

    Opencl编程的标准开发流程 前言 OpenCL执行流程 模板 前言 在前面的内容中介绍 了opencl编程环境的搭建方式环境搭建,本篇文章以为例讲述opencl编程的标准开发流程 编程环境:VS2 ...

  7. ASP.NET CORE 第四篇 依赖注入IoC学习 + AOP界面编程初探

    原文作者:老张的哲学 更新 1.如果看不懂本文,或者比较困难,先别着急问问题,我单写了一个关于依赖注入的小Demo,可以下载看看,多思考思考注入的原理: https://github.com/anjo ...

  8. 从壹开始前后端分离【 .NET Core2.2 +Vue2.0 】框架之九 || 依赖注入IoC学习 + AOP界面编程初探...

    更新 1.如果看不懂本文,或者比较困难,先别着急问问题,我单写了一个关于依赖注入的小Demo,可以下载看看,多思考思考注入的原理: https://github.com/anjoy8/BlogArti ...

  9. OpenCL编程指南-1.1OpenCL简介

    什么是OpenCL OpenCL是面向由CPU.GPU和其他处理器组合构成的计算机进行编程的行业标准框架.这些所谓的 "异构系统" 已经成为一类重要的平台,OpenCL是直接满足这 ...

最新文章

  1. 中国免检制度可能全面废止 产品免检办法已废除
  2. 永远不要相信用户的输入
  3. Exynos 4412启动过程(群聊笔记记录)
  4. linux apache 负载均衡,使用Apache作为前端负载均衡器
  5. c语言斐波那契数列_视频丨神奇的斐波那契数列科学性与艺术性
  6. python+selenium获取cookie session_selenium获取cookie及设置cookie
  7. 福建品品香茶业有限公司业务迁移上云
  8. 详解智慧城市排水管理系统整体方案
  9. echarts社区饼图 echart饼图 玫瑰图
  10. 第二章 进程的描述与控制【操作系统】
  11. 堡垒机JumpServer(六):内网管理云端服务器
  12. c++实现STL标准库
  13. SpringBoot集成BBOSS-ElasticSearch实现ElasticSearch客户端
  14. 微信小程序常用视图容器组件
  15. 什么是XSL,它有什么用途
  16. 我国计算机领域研究的状况文档,计算机应用现状与发展趋势.doc
  17. 社区宽带繁忙是什么意思_嗖!开发区宽带网速已提升至千兆
  18. pytorch - swa_model模型保存的问题
  19. 简单快捷的 Python 爬虫工具:SmartScraper
  20. iOS审核-17次被打回的完整记录 2020/6/1

热门文章

  1. element el-table 表格行列合并[{class1:‘1101‘,arr1:[1,2,3,5],class2:‘1102‘,arr2:[4,5,6],name:‘h‘}]
  2. Vue前端框架的使用
  3. C++的双缓冲队列机制
  4. python读取txt文件写入失败-Python write 函数写文件失败
  5. Surf函数调节图像方法
  6. Catalan number (卡兰特数)
  7. c语言API用法 查询
  8. Python读文件与写文件
  9. ubuntu16.04下Nvidia T1000显卡驱动460、CUDA10.2、CUDNN8安装
  10. 软件工程师的职业规划