博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CUDA搭建
阅读量:7233 次
发布时间:2019-06-29

本文共 3516 字,大约阅读时间需要 11 分钟。

  hot3.png

参考http://blog.csdn.net/tjusxh/article/details/48463409

参考 

 

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

 

安装python2.7.11 64bit

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

 

首先测试是否支持CUDA7.5

 

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

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

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

运行代码

#include 
 #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;}

 

 

转载于:https://my.oschina.net/qiyong/blog/545870

你可能感兴趣的文章
为什么 kubernetes 天然适合微服务 (2)
查看>>
EMQ 配置
查看>>
Python--面向对象进阶
查看>>
偏向锁状态转移原理
查看>>
Angular5升级至Angular7
查看>>
通过VuePress管理项目文档(一)
查看>>
webpack-chain项目中文翻译
查看>>
JavaScript 数组操作方法小结
查看>>
关于 ClojureScript 裸写 stateful React Component
查看>>
gson-plugin深入源码分析(三)
查看>>
leetcode-846-Hand of Straights
查看>>
rpm包管理功能全解
查看>>
web前端开发编码规范及性能优化
查看>>
安装LNMP开发环境
查看>>
谈谈前端性能优化(一)
查看>>
Spring Boot Web 应用性能优化
查看>>
关于ThinkPHP5中使用 Auth2 验证的实现
查看>>
iOS火焰动画效果、图文混排框架、StackView效果、偏好设置、底部手势等源码
查看>>
python--模块2
查看>>
Spring Cloud 配置中心内容加密
查看>>