Win7 64-bit command-line compile cuda and set Windows graphics response time

Source: Internet
Author: User
Tags nvcc

Find Visual Studio >> Visual Studio Tools in the Start menu

Choose the 86 or 64 version of the VC command prompt environment that I use

VS2013 x86 Native Tools Command Prompt

This should configure the path of the VC compiler, and the path of the NVCC (cuda C compiler) in the environment variable.

And then enter

NVCC Cudafilename.cu-o Outfilename

This format, such as

NVCC Hello.cu-o Hello

The Hello.cu file is compiled, and the Hello.exe file is generated

By the way, if you are curious, you will certainly take VS2015 command prompt environment to try once, but certainly will fail, this again illustrates that Cuda fundamentally does not support VS2015, want to use Cuda in VS2015 only wait for the official

============================================================

Take a look at the response time, the following test code in my notebook GeForce GT 755m about 8 seconds to run (in mind, no actual test time), if it appears

Graphics driver stops responding and has recovered successfully

The test is successful, if not, you can modify the number of cycles, multiply by 2 or by 10, depending on the strength of your graphics card to look at

1#include <iostream>2 3#include <cuda.h>4#include <cuda_runtime.h>5#include <device_launch_parameters.h>6 7 using namespacestd;8 9__global__voidAddintscuda (intAint*b)Ten { One      for(inti =0; I <40000000; ++i) A     { -a[0] + = b[0]; -     } the      - } -  - intMain () + { -     intH_a =0; +     intH_b =1; A  at     int*d_a; -     int*d_b; -  -     if(Cudamalloc (&d_a,sizeof(int)) !=cudasuccess) -     { -cout <<"Error CUDA allocating memory"<<Endl; in         return 0; -     } to     if(Cudamalloc (&d_b,sizeof(int)) !=cudasuccess) +     { -cout <<"Error CUDA allocating memory"<<Endl; the Cudafree (d_a); *         return 0; $     }Panax Notoginseng  -     if(cudamemcpy (d_a, &h_a,sizeof(int), cudamemcpyhosttodevice)! =cudasuccess) the     { +cout <<"Error CUDA Copying memory"<<Endl; A Cudafree (d_a); the Cudafree (d_b); +         return 0; -     } $     if(cudamemcpy (D_b, &h_b,sizeof(int), cudamemcpyhosttodevice)! =cudasuccess) $     { -cout <<"Error CUDA Copying memory"<<Endl; - Cudafree (d_a); the Cudafree (d_b); -         return 0;Wuyi     } the  -Addintscuda << <1,1>> >(d_a, d_b); Wu  -     if(cudamemcpy (&h_a, D_a,sizeof(int), cudamemcpydevicetohost)! =cudasuccess) About     { $cout <<"Error CUDA Copying memory"<<Endl; - Cudafree (d_a); - Cudafree (d_b); -         return 0; A     } +  the     if(cudamemcpy (&h_b, D_b,sizeof(int), cudamemcpydevicetohost)! =cudasuccess) -     { $cout <<"Error CUDA Copying memory"<<Endl; the Cudafree (d_a); the Cudafree (d_b); the         return 0; the     } -  incout <<"H_a is:"<< h_a <<Endl; the  the Cudafree (d_a); About Cudafree (d_b); the  the     //Cudadevicereset must is called before exiting in order for profiling and the     //tracing tools such as Nsight and Visual Profiler to show complete traces. +cudaerror_t Cudastatus =Cudadevicereset (); -     if(Cudastatus! =cudasuccess) { thefprintf (stderr,"Cudadevicereset failed!");Bayi         return 1; the     } the  -  -     return 0; the}

This indicates that the program takes too long, the default appears to be 2 seconds, Windows does not receive the video card response

Workaround, to change the registry, it is recommended to back up the registry, just in case

5.00 [Hkey_local_machine\system\currentcontrolset\control\graphicsdrivers] " Tdrlevel "=dword:00000000"tdrdelay"=dword:00000020

Tdrdelay is the delay time, change their feelings can be on the line, I use the 0x20, see a tutorial casually follow write, but the general program should not run so long

It's all about testing, but it's not a good idea to write a "crappy" magic algorithm to run a 5 minute, 10 minutes, maybe.

Win7 64-bit command-line compile cuda and set Windows graphics response time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.