Win7命令行编译cuda及设置Windows显卡响应时间
在开始菜单中找到Visual Studio 2013 >> Visual Studio Tools
选择86或64版本的VC命令提示符环境,我用的
VS2013 x86 Native Tools Command Prompt
这样应该就会配置好VC编译器的Path,环境变量中又有nvcc(cuda的c编译器)的Path
然后输入
nvcc cudaFileName.cu -o outFileName
这种格式,比如
nvcc hello.cu -o hello
就会编译hello.cu文件,生成hello.exe文件
顺便你如果好奇,肯定会拿VS2015的命令提示符环境试一次,但是肯定会失败,这再次说明了cuda从根本上就不支持VS2015,想在VS2015中使用cuda只能等待官方
============================================================
再来看看响应时间,下面的测试代码在我的笔记本Geforce GT 755m上大概要跑8秒(心里估算,没实际测试具体时间),如果出现
显卡驱动停止响应并已成功恢复
说明测试成功了,如果没出现,你可以修改一下那个循环数,乘2或者乘10之类的根据自己的显卡强度看着来
#include <iostream> #include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h> using namespace std; __global__ void AddIntsCUDA(int* a, int* b)
{
for (int i = ; i < ; ++i)
{
a[] += b[];
} } int main()
{
int h_a = ;
int h_b = ; int* d_a;
int* d_b; if (cudaMalloc(&d_a, sizeof(int)) != cudaSuccess)
{
cout << "Error CUDA allocating memory" << endl;
return ;
}
if (cudaMalloc(&d_b, sizeof(int)) != cudaSuccess)
{
cout << "Error CUDA allocating memory" << endl;
cudaFree(d_a);
return ;
} if (cudaMemcpy(d_a, &h_a, sizeof(int), cudaMemcpyHostToDevice) != cudaSuccess)
{
cout << "Error CUDA copying memory" << endl;
cudaFree(d_a);
cudaFree(d_b);
return ;
}
if (cudaMemcpy(d_b, &h_b, sizeof(int), cudaMemcpyHostToDevice) != cudaSuccess)
{
cout << "Error CUDA copying memory" << endl;
cudaFree(d_a);
cudaFree(d_b);
return ;
} AddIntsCUDA << <, >> >(d_a, d_b); if (cudaMemcpy(&h_a, d_a, sizeof(int), cudaMemcpyDeviceToHost) != cudaSuccess)
{
cout << "Error CUDA copying memory" << endl;
cudaFree(d_a);
cudaFree(d_b);
return ;
} if (cudaMemcpy(&h_b, d_b, sizeof(int), cudaMemcpyDeviceToHost) != cudaSuccess)
{
cout << "Error CUDA copying memory" << endl;
cudaFree(d_a);
cudaFree(d_b);
return ;
} cout << "h_a is : " << h_a << endl; cudaFree(d_a);
cudaFree(d_b); // cudaDeviceReset must be called before exiting in order for profiling and
// tracing tools such as Nsight and Visual Profiler to show complete traces.
cudaError_t cudaStatus = cudaDeviceReset();
if (cudaStatus != cudaSuccess) {
fprintf(stderr, "cudaDeviceReset failed!");
return ;
} return ;
}
出现这个说明程序运时时间过长,默认好像是2秒,windows接收不到显卡的响应
解决办法,改注册表,建议先备份注册表,以防万一
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers]
"TdrLevel"=dword:
"TdrDelay"=dword:
TdrDelay是延时时间,改个自己感觉可以的就行了,我用的0x20,看某教程随便跟着写的,不过一般程序应该也不会运行这么久
完全是测试,但是指不定哪天突然想写个“蹩脚”的神奇算法要运行个5分10分钟的,也许用得上,谁知道呢
Win7命令行编译cuda及设置Windows显卡响应时间的更多相关文章
- Win7 64位命令行编译cuda及设置Windows显卡响应时间
在开始菜单中找到Visual Studio 2013 >> Visual Studio Tools 选择86或64版本的VC命令提示符环境,我用的 VS2013 x86 Native To ...
- windows下cmd命令行显示UTF8字符设置(CHCP命令)
本文由 www.169it.com 收集整理 在中文Windows系统中,如果一个文本文件是UTF-8编码的,那么在CMD.exe命令行窗口(所谓的DOS窗口)中不能正确显示文件中的内容.在默认情况下 ...
- Windows下搭建Android NDK开发环境及命令行编译
首先说明本文内的相关安装操作参考<Pro Android C++ with the NDK>一书. 安装 Windows搭建Android NDK开发环境需要安装如下部分(同时需要配置对应 ...
- msvc交叉编译:使用vcvarsall.bat设置命令行编译环境
一直以来我只知道vc设置命令行编译环境的批处理命令是%VS140COMNTOOLS%/Common7/Tools下的vsvars32.bat,(%VS140COMNTOOLS%为定义vs2015公共工 ...
- Windows下使用命令行编译Qt项目(解决DLL丢失问题)
一.前言 我之前用Qt做了个hello world,结果各种报错,一大堆DLL找不到,今天用命令行编译就通过了 二.准备工作 1.Visual Studio(有nmake就行) 2.Qt 3.把qma ...
- 基于命令行编译打包phonegap for android应用 分类: Android Phonegap 2015-05-10 10:33 73人阅读 评论(0) 收藏
也许你习惯了使用Eclipse编译和打包Android应用.不过,对于使用html5+js开发的phonegap应用,本文建议你抛弃Eclipse,改为使用命令行模式,绝对的快速和方便. 一直以来,E ...
- VS2010命令行编译C#和VC项目
VS2010命令行编译C#和VC项目 VS2010命令行编译C#和VC项目 根据需要动态创建数据库字段后,需要动态创建或者调整页面,那就需要编译这些页面和后台文件.因此使用命令行编译将会非常方便,对于 ...
- VMware10中的CentOS6.5命令行安装VMwaretools工具启用windows与虚拟机中Linux系统的共享目录
VMware10中的CentOS6.5命令行安装VMwaretools工具启用windows与虚拟机中Linux系统的共享目录 一.描述 系统描述:win7旗舰版64位系统+VMware Workst ...
- 2016/01/10 C++ Primer 小记 —— 命令行编译环境配置
OK!第一篇博文!自贺一下! 今日看了此书的前几页.嗯,说得挺全,基础易懂. 之前学过c++,但没用过命令行编译. 本人用的VS里的编译器,文件名是cl.exe,在VC目录下. 虽然有了编译器,但并不 ...
随机推荐
- 【js语法】array
array操作说明 链接:http://www.w3school.com.cn/jsref/jsref_obj_array.asp 函数说明: concat():把两个array连接起来 join() ...
- seek引发的python文件读写的问题
我的需求很简单,就是统计一下我的安装脚本执行的次数和时间,格式是这样的 install_times:1|install_times:2018-09-03 15:58:46 install_times: ...
- POPUP_TO_CONFIRM的使用方法
CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING TEXT_QUESTION = '是否要打印凭证!' ...
- 组委会正在为美团点评CodeM大赛的决赛设计新赛制
比赛有 n 个人参加(其中 n 为2的幂),每个参赛者根据资格赛和预赛.复赛的成绩,会有不同的积分.比赛采取锦标赛赛制,分轮次进行,设某一轮有 m 个人参加,那么参赛者会被分为 m/2 组,每组恰好 ...
- Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead.解决方法
今天在eclipse里报这个错误: Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead. Please ...
- 关于控制反转(IOC)容器 ,依赖注入(DI)模式必读文章收集
推荐一篇国外設計大師Martin Fowler的大作:Inversion of Control Containers and the Dependency Injection pattern http ...
- Junit4知识梳理
一.junit官网 junit4:http://junit.org/junit4/ junit5:http://junit.org/junit5/ 二.github junit4: https://g ...
- Java 内存模型、GC原理及算法
Java 内存模型.GC原理:https://blog.csdn.net/ithomer/article/details/6252552 GC算法:https://www.cnblogs.com/sm ...
- Eclipse中的maven项目搭建
一.eclipse中的maven设置 1.打开“首选项”----> "maven"---->"Installations".用来查看maven的使用 ...
- Android.DebugOnDevices
真机调试Android http://www.cnblogs.com/junqilian/archive/2012/11/08/2760734.html