win10安装cuda

 

精简模式安装cuda9  

  • 默认路径,不要改到D盘。
  • 不要选择自定义模式,用精简模式。选了自定义模式,哪怕不改路径,在编译Samples的时候,还是会报路径错误。查看后发现,在找不到文件的路径下,文件的版本不对,还是旧版本,就算手动改成现在的版本,后面又会报版本错误。可能是因为自定义模式没有改VC++库里相关的属性。后来直接用精简模式就好了。
未找到导入的项目“D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\...\CUDA 9.0.props

 

 

CUDA Samples测试:

1. 打开C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.2\里的Samples_vs2017.exe

2. 载入成功后,选择任意一个项目,如Simulations\oceanFFT,调整好项目属性:

  - 《win10安装cuda》

 

  - 第一次生成时出现错误:

unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!

  解决办法:修改CUDA头文件(原文:https://blog.csdn.net/u010974701/article/details/79807190)

      • 打开 – %CUDA_PATH%\include\crt\host_config.h –
      • #if _MSC_VER < 1600 || _MSC_VER > 1911
        //把1911 改为1920即可,保存

         

《win10安装cuda》

 (感人。。。)

 

由cuda9.2改为cuda9.0

– 由于在import tensorflow as tf时,出现了找不到cuxxx_90.*的错误,对应路径下的文档是cuxxx_92.*,所以将一开始安装的cuda9.2卸载,从新安装cuda9.0。除了之前遇到的问题,还遇到了下面的报错(截了一小段):

1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\xtr1common(59): error : class "std::enable_if<<error-constant>, void>" has no member "type"
1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\xmemory0(364): error : expression must have a constant value
1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\xmemory0(982): error : expression must have a constant value
1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\xmemory0(1311): error : expression must have a constant value
1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\xstring(1922): error : expression must have a constant value
1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\xutility(301): error : expression must have a constant value
1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\memory(1454): error : expression must have a constant value
1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\memory(1461): error : expression must have a constant value
1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\memory(2507): error : expression must have a constant value
1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include\xstring(1984): error : more than one instance of overloaded function "std::_Deallocate_plain" matches the argument list:

  解决办法:

  • 参考:https://devtalk.nvidia.com/default/topic/1022648/cuda-setup-and-installation/cuda-9-unsupported-visual-studio-version-error/3
  • 安装VS2015 SDK,在项目属性中,设置平台工具集为VS2015,(这里顺便把Windows SDK 版本也换成了默认的10.0.15063.0),这样后续也不用改SDK版本了。
  • 生成的执行文档在C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.0\bin\win64\Debug里。

  《win10安装cuda》

测试tensorflow是否使用GPU:

>>> import tensorflow as tf
D:\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
>>> a = tf.test.is_built_with_cuda()  # 判断CUDA是否可以用
>>> b = tf.test.is_gpu_available(
...     cuda_only=False,
...     min_cuda_compute_capability=None
... )                                  # 判断GPU是否可以用
2018-07-26 16:19:56.860793: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2018-07-26 16:19:57.224782: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1392] Found device 0 with properties:
name: GeForce GTX 1050 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.392
pciBusID: 0000:01:00.0
totalMemory: 4.00GiB freeMemory: 3.29GiB
2018-07-26 16:19:57.232122: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1471] Adding visible gpu devices: 0
2018-07-26 16:22:34.485518: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-07-26 16:22:34.489209: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:958]      0
2018-07-26 16:22:34.491046: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0:   N
2018-07-26 16:22:34.493085: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1084] Created TensorFlow device (/device:GPU:0 with 3019 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
>>>
>>> print(a)
True
>>> print(b)
True

 

 总结:

Win10 + 1050Ti + Cuda9.0 + Keras + Tensorflow + VS2017的安装:

– 之前已经安装过Anaconda,Tensorflow,Keras, VS2017。

– 下载CUDA9.0精简模式安装。

– 用VS2017 installer安装VS2015(v140)平台工具集,以及对应的SDK(10.0.15063.0)

(否则会出现各种报错比如,找不到源文件,expect contant value等等)。

– 安装DXSDK_Jun10(不知道干什么用,按攻略来的)。

– 下载cuDNN9.0(对应版本),解压后放在C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0。

– 测试CUDA Samples的时候,项目属性的平台工具集选VS2015。

– 必要的话改一下CUDA头文件。

– 安装pip install tensorflow-gpu。

– 测试。

 

《win10安装cuda》

(终于看到GPU被用起来了。。。)

    原文作者:nnexp
    原文地址: https://www.cnblogs.com/expttt/p/9369728.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞