win7+VS2010如何安装CUDA7.0

2023-05-14,,

这篇文章将为大家详细讲解有关win7+VS2010如何安装CUDA7.0,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

win7+ VS2010安装CUDA7.0图文说明

1.      查看本机配置,查看显卡类型是否支持NVIDIA GPU,选中计算机--> 右键属性 --> 设备管理器 --> 显示适配器:NVIDIA GeForce GT 610,从https://developer.nvidia.com/cuda-gpus可以查到相应显卡的compute capability;

2.      从http://www.nvidia.cn/Download/index.aspx?lang=cn下载合适驱动347.88-desktop-win8-win7-winvista-64bit-international-whql.exe 并安装;

3. 从https://developer.nvidia.com/cuda-toolkit   根据本机类型下载相应的最新版本CUDA7.0安装;

4.按照http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-microsoft-windows/index.html#axzz3W8BU10Ol  步骤,验证是否安装正确:

         (1)、打开C:\ProgramData\NVIDIACorporation\CUDA Samples\v7.0目录下的Samples_vs2010.sln工程,分别在Debug、Release x64下编译整个工程;

         (2)、编译过程中,会提示找不到”d3dx9.h”、”d3dx10.h”、”d3dx11.h”头文件,可以从http://www.microsoft.com/en-us/download/details.aspx?id=6812下载DXSDK_Jun10.exe,然后安装到默认目录下;再编译工程即可;

如果安装DXSDK_Jun10.exe出错,如下图

 

解决办法:

打开“控制面板”的“程序和功能”,果然计算机里之前有安装“Microsoft Visual C++ 2010 x86 Redistributable - 1010.0.40219”,而DXSDK_Jun安装的是“Microsoft Visual C++ 2010 x86 Redistributable - 1010.0.30319”,版本低于本机已安装的版本,所以安装出现s1023错误。

卸载更高的版本“Microsoft Visual C++ 2010 x86 Redistributable - 1010.0.40219”和“Microsoft Visual C++ 2010 x64 Redistributable - 1010.0.40219”,再重新安装即可。

重新启动vs2010,即可编译通过。

(3)、打开C:\Program Files\NVIDIA Corporation\Installer2\CUDASamples_7.0.{658B19AF-1B62-4FD6-A2B7-9E653E4F2B7A}\bin\win64\Release目录,打开cmd命令行,将deviceQuery.exe直接拖到cmd中,回车,会显示GPU显卡、CUDA版本等相关信息,最后一行显示:Result = PASS;

         (4)、将bandwidthTest.exe拖到cmd中,回车,会显示Device0: GeForce GT 610等相关信息,后面也会有一行显示:Result = PASS;      

5. 配置VS2010

(1)、打开VS2010,新建工程,选win32,记得勾选”空项目“。

(2)、右键源文件->添加新建项->选择CUDA C/C++File,名字任意了。

 

(3)、右键工程->生成自定义->勾选CUDA 5.5

 

(4)、右键main.cu->属性->项类型  选择"CUDA C/C++"

 

(5)、右键工程->属性->链接器->常规->附加库目录->添加目录$(CUDA_PATH_V7_0)\lib\$(Platform);

(6)、链接器->输入->附加依赖项 添加cudart.lib

(7)、在main.cu中加入代码,示例代码如下:

    #include< stdio.h> 

    #include "cuda_runtime.h" 

    #include "device_launch_parameters.h" 

    bool InitCUDA() 

    { 

        int count; 

        cudaGetDeviceCount(&count); 

        if(count == 0) 

        { 

            fprintf(stderr, "There is no device.\n"); 

            return false; 

        } 

        int i; 

        for(i = 0; i < count; i++) 

        { 

            cudaDeviceProp prop; 

            if(cudaGetDeviceProperties(&prop, i) == cudaSuccess) 

            { 

                if(prop.major >= 1) 

                { 

                    break; 

                } 

            } 

        } 

        if(i == count) 

        { 

            fprintf(stderr, "There is no device supporting CUDA 1.x.\n"); 

            return false; 

        } 

        cudaSetDevice(i); 

        return true; 

    } 

    int main() 

    { 

        if(!InitCUDA()) 

        { 

            return 0; 

        } 

        printf("HelloWorld, CUDA has been initialized.\n"); 

        return 0; 

    } 

windows7 64位 显卡GT640M cuda7.5

下载了最新版本的cuda

http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_windows.exe

安装python2.7.11 64bit

https://www.python.org/downloads/windows/

首先测试是否支持CUDA7.5

http://blog.sina.com.cn/s/blog_534497fd0102vbu3.html

打开C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5mu中.sln文件,在vs2012中打开,调试。

建立win32空工程,添加链接附件库目录$(CUDA_PATH_V7_5)\lib\$(Platform),添加链接 输入  附加依赖项cudart.lib

添加cuda代码 并在代码属性中设置项类型CUDA C/C++

运行代码

#include <stdio.h>
 #include "cuda_runtime.h" 
 #include "device_launch_parameters.h" 
bool InitCUDA()
{
    int count;

    cudaGetDeviceCount(&count);

    if(count == 0)
    {
        fprintf(stderr, "There is no device.\n");
        return false;
    }

    int i;

    for(i = 0; i < count; i++)
    {
        cudaDeviceProp prop;

        if(cudaGetDeviceProperties(&prop, i) == cudaSuccess)
        {
            if(prop.major >= 1)
            {
                break;

            }
        }
    }

    if(i == count)
    {
        fprintf(stderr, "There is no device supporting CUDA 1.x.\n");
        return false;
    }

    cudaSetDevice(i);

    return true;
}

int main()
{
    if(!InitCUDA())
    {
        return 0;
    }

    printf("HelloWorld, CUDA has been initialized.\n");

    return 0;
}

关于“win7+VS2010如何安装CUDA7.0”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

《win7+VS2010如何安装CUDA7.0.doc》

下载本文的Word格式文档,以方便收藏与打印。