接着前面有篇文章介绍在windows上面对他们进行合成,这篇文章我们介绍下在ubuntu上面对其合成。

程序用的是brown大学里面snow-master,该project包括了几个项目,其中有个CUDA_helloworld刚好可以拿来练手

CUDA在ubuntu上面的安装我就不多介绍,攻略帖一大堆

下面开始介绍下这个项目

main.cpp内容如下:

#include <QCoreApplication>extern "C" // tell compiler that function is defined somewhere elsevoid runCudaPart();#include <stdio.h>int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);runCudaPart();return a.exec();
}

kernel.cu内容如下:

#include <cuda.h>
#include <glm/glm.hpp>
#include <stdio.h>#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ < 200)# error printf is only supported on devices of compute capability 2.0 and higher, please compile with -arch=sm_20 or higher
#endifextern "C"
void runCudaPart();__global__ void helloCUDA(glm::vec3 v)
{int tid = blockIdx.x;printf("Hello block %d thread %d, x=%f\n",tid , threadIdx.x, v.x);
}void runCudaPart()
{// all your cuda code hereglm::vec3 v(0.1f, 0.2f, 0.3f);
//    helloCUDA<<<1, 5>>>(v); // 1 block, 5 GPU threadshelloCUDA<<<5,1>>>(v); // 5 blocks, 1 GPU thread eachcudaDeviceSynchronize();
}

其中项目的pro文件如下:

#-------------------------------------------------
#
# Project created by QtCreator 2014-04-03T18:12:01
#
#-------------------------------------------------QT       += core
QT       -= guiTARGET = CUDA_helloworld
CONFIG   += console
CONFIG   -= app_bundleTEMPLATE = appSOURCES += main.cpp# GLM
INCLUDEPATH += /usr/local/glm# C++ flag
QMAKE_CXXFLAGS_RELEASE=-O3# CUDA stuff
CUDA_SOURCES += kernel.cu# uncomment below to also import include CUDA SDK
#CUDA_SDK = /contrib/projects/cuda-sdk/C
#INCLUDEPATH += $$CUDA_SDK/common/inc/
#INCLUDEPATH += $$CUDA_SDK/../shared/inc/
#QMAKE_LIBDIR += $$CUDA_SDK/lib
#QMAKE_LIBDIR += $$CUDA_SDK/common/libCUDA_DIR = /usr/local/cuda-7.5
INCLUDEPATH += $$CUDA_DIR/include
QMAKE_LIBDIR += $$CUDA_DIR/lib64
#LD_LIBRARY_PATH=$${LD_LIBRARY_PATH}:$$CUDA_DIR/lib64
#message($${LD_LIBRARY_PATH})#$$(PATH) = $$(PATH):$$CUDA_DIR/bin
#message($$(PATH))LIBS += -lcudart -lcudaOTHER_FILES += \CUDA_notes.txt \kernel.cu# GPU ARCH
# this gets passed as the gpu-architecture flag to nvcc compiler
# specifying particular architectures enable certain features, limited to the compute capability
# of the GPU. compute capabilities listed here http://en.wikipedia.org/wiki/CUDA
# MSLAB GeForce 460 seems to have compute capability 2.1
CUDA_ARCH = sm_21# custom NVCC flags
NVCCFLAGS     = --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v# Prepare the extra compiler configuration (taken from the nvidia forum - i'm not an expert in this part)
CUDA_INC = $$join(INCLUDEPATH,' -I','-I',' ')# compile CUDA kernels using nvcc
cuda.commands = $$CUDA_DIR/bin/nvcc -m64 -g -G -arch=$$CUDA_ARCH -c $$NVCCFLAGS $$CUDA_INC $$LIBS  ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} \2>&1 | sed -r \"s/\\(([0-9]+)\\)/:\\1/g\" 1>&2
# Prepare the extra compiler configuration (taken from the nvidia forum - i'm not an expert in this part)
cuda.input = CUDA_SOURCES
cuda.output = ${OBJECTS_DIR}${QMAKE_FILE_BASE}_cuda.o # suffix needed for this to work?
# Tell Qt that we want add more stuff to the Makefile
QMAKE_EXTRA_UNIX_COMPILERS += cuda

配置好后运行,会出现

libcudart.so.7.5: cannot open shared object file: No such file or directory

网上搜了下,解决方法如下

在shell中输入:

32-bit: sudo ldconfig /usr/local/cuda-7.5/lib

64-bit: sudo ldconfig /usr/local/cuda-7.5/lib64

cheers!

QT+CUDA7.5+UBUNTU14.04相关推荐

  1. 【Qt】在ubuntu14.04上安装Qt5.12(失败)

    注意 在ubuntu14.04上安装Qt5.12最终失败了,Qt5.12需要的libdbus库的版本和ubuntu14.04中的不一致,如果强行升级libdbus库版本,会导致系统桌面无法启动. 再次 ...

  2. Qt简介、安装及在Ubuntu14.04 32位上简单使用举例

    Qt是一个跨平台的C++图形用户界面应用程序开发框架.它既可以开发GUI程序,也可用于开发非GUI程序.Qt是面向对象的框架,很容易扩展.Qt是一个C++工具包,它由几百个C++类构成,你在程序中可以 ...

  3. ubuntu14.04.5装cuda7.5记录(解决unable to locate the kernel source,装cuda黑屏问题,装cuda循环登录问题)

    ubuntu14.04.5装cuda7.5记录(解决unable to locate the kernel source,装cuda黑屏问题,装cuda循环登录问题) 参考文章: (1)ubuntu1 ...

  4. caffe linux 教程,Caffe 深度学习入门教程 - 安装配置Ubuntu14.04+CUDA7.5+Caffe+cuDNN_Linux教程_Linux公社-Linux系统门户网站...

    安装配置Ubuntu14.04+CUDA7.5+Caffe+cuDNN 一.版本 Linux系统:Ubuntu 14.04 (64位) 显卡:Nvidia K20c cuda: cuda_7.5.18 ...

  5. ubuntu14.04+CUDA7.5+cuDNN+caffe的超详细完整配置

    版权声明:文章原创,转载请注明出处,多谢! 声明 本文是关于ubuntu14.04+CUDA7.5+cuDNN+caffe的超详细完整配置过程的说明. 小菜是刚接触深度学习领域的小白,在配置caffe ...

  6. ubuntu14.04+cuda7.0+opencv2.4.9

    安装了ubuntu14.04 分辨率有问题,于是安装英伟达显卡驱动,一个比较简单地方法就是安装Cuda,这里安装的是Cuda7.0版本. 原文地址:http://blog.csdn.net/alten ...

  7. Ubuntu14.04 安装CUDA7.5 + Caffe + cuDNN

    花了一天时间,在电脑上安装配置了Caffe深度学习框架,网上的很多教程和指导都已经过期,中间辗转耗费了点时间,这里把个人认为最简单的方法整理如下. 1 版本 笔记本:ThinkPad W541 Ubu ...

  8. linux qt搜狗输入法用不,Ubuntu14.04下搜狗输入法不支持Qt5环境

    问题环境确认: 系统平台Ubuntu14.04/ 安装了搜狗输入法/ 安装Qt5.4.1 一般自定义下载来Qt软件包,安装之后,都会有这个问题,在Qt环境下或Qt Creator下不能切换输入法,也不 ...

  9. 【Qt】ubuntu14.04.5 qt5.6中使用opencv3.4报错:Using GTK+ 2.x and GTK+ 3 in the same process is not supported

    问题描述 ubuntu14.04.5 qt5.6中使用opencv3.4报错: Using GTK+ 2.x and GTK+ 3 in the same process is not support ...

最新文章

  1. ipmsg 绑定tcp错误
  2. 优雅得使用composer来安装各种PHP小工具
  3. dmc matlab程序,matlab编的DMC程序.doc
  4. HDU5763 Another Meaning(KMP+dp)
  5. “音”你而来,“视”而可见 腾讯云+社区音视频技术开发实战沙龙圆满结束...
  6. Spring+hibernate+JSP实现Piano的数据库操作---1.目录结构+展示
  7. git status命令
  8. 进入大厂的面试经验详细总结(P7 拿 offer)
  9. C语言 谭浩强第五版 课后习题解答
  10. oracle 创建表格乱码,数据库导出excel表格是乱码怎么办-oracle 导出excel 乱码怎么办...
  11. 信息系统管理——项目立项管理(详细可行性研究的结构)
  12. Go Grpc Jwt身份认证和Gateway集成以及HTTPS双向认证
  13. excel 合并单元格筛选
  14. C盘扩容_解决过程记录
  15. 【Linux】 - Linux中查看命令文档的命令
  16. 《人性的弱点全集》- [美]戴尔·卡耐基/著
  17. 从零搭建外卖CPS外卖公众号教程,为你带来睡后收入
  18. 黑马程序员匠心之作|C++教程从0到1入门编程(基础)
  19. 图片下载_二维码生成
  20. element-ui 去掉谷歌浏览器el-input组件或input自动填充账号密码

热门文章

  1. 将MFC Grid Control封装为DLL的做法及其在DLL中的使用方法
  2. backgroundworker 在执行dowork事件时该如何取消_澳航官宣!明年上半年起,机场所有售票处和服务台永久取消,订票改签等只能“自助”...
  3. ubtil类oracle,oracle中报错Connect internal only, until freed
  4. 山西首次举办明清水陆画专题展 多数藏品首次面世
  5. 2018下半年软考报名
  6. Beta 冲刺 (6/7)
  7. 4、Windows2008 R2安装Vcenter5.0
  8. BZOJ 1492 货币兑换Cash
  9. java中用单例模式有什么好处
  10. .NET常见错误大全