win10+cuda10.2+cudnn7.6.5+TensorFlow2.3.0 深度神经网络环境搭建

1. 确认能安装的CUDA版本

win10 一般都有对应的显卡驱动,若没安装的,可以提前利用驱动软件进行安装更新或进入英伟达官网进行下载

查看可使用的CUDA版本

桌面右键——>打开英伟达控制面板
若是桌面右键没有这个选项,可以利用左下角快速搜索,搜索 NVIDIA Control Panel进行打开。
在这里插入图片描述
在这里插入图片描述
进入系统信息 —— 组件,可以看到当前驱动程序支持的 CUDA 版本,此电脑支持的版本为 10.2.104,因此需要从英伟达官网下载10.2的CUDA版本。
在这里插入图片描述
ps:后面发现,其实不需要过多关心此处的版本号,本文用的 cuda 10.2 其实不在 tensorflow 支持的范围内,但莫慌,可以正常使用。需要关心的点有4个:

  1. 当前显卡最高支持的驱动版本,以及其支持最高 cuda 版本
  2. 想要下载的 tensorflow 版本及其对应的 cuda 版本(例如 tensorflow 2.3.0 对应 cuda 10.1、tensorflow 2.4.0 对应 cuda 11.0)
  3. 取上面两点最小的 cuda 版本号进行安装 (不是版本越高越好,是适合的才好,没有那么多坑,埋坑并不能提高技术水平。。。)
  4. 下载 cuda 版本对应的 cudnn 版本

2.下载 CUDA Toolkit

CUDA 各版本下载连接 — 此处可能需要自备梯子才能打开网页和下载
在这里插入图片描述
由于我下载在线安装的版本时安装失败,因此选了本地安装包进行下载。
在这里插入图片描述
小提示:实测利用迅雷下载,会有明显提速,并且不需要梯子也可以进行下载,CUDA 10.2 迅雷下载连接

3.安装 CUDA 10.2

双击下载好的离线安装包,建议安装路径都选用默认路径,若是 C盘空间不足,请务必记录安装过程中设置的路径,后续需要使用。
在这里插入图片描述
选择自定义安装
在这里插入图片描述
去除 Visual Studio Integration 选项
在这里插入图片描述
保持默认路径设置,若需要修改,请务必记录好路径
在这里插入图片描述
下一步等待安装结束。
在系统变量中,添加下面的 PATH 环境变量

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\lib\x64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\extras\CUPTI\lib64
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v10.2\bin\win64
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v10.2\common\lib\x64

验证是否安装成功
打开 CMD ,执行查看 CUDA 版本的命令

nvcc -V

显示版本信息,安装成功!
在这里插入图片描述

4. 安装 cudnn

需要注册登录 nvidia 开发者账号才能进行下载 下载页面
展开所有选项
在这里插入图片描述
找到 cudnn 7.6.5 for CUDA 10.2
在这里插入图片描述
小提示:可以利用迅雷进行下载 cudnn 7.6.5 zip

下载下来是一个压缩包,解压之后有3个文件夹
在这里插入图片描述
将这三个文件夹,直接复制到 cuda 安装目录下,
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2

完成 CUDA+CUDNN 的环境安装

5.TensorFlow 测试

创建 conda 环境

若是没有安装 anaconda 的话,可以参考这篇文章进行安装,(ubuntu 与 win10 几乎通用)https://blog.csdn.net/qq_29225913/article/details/105347317

直接从开始菜单打开 anaconda CMD 环境 Anaconda Prompt
更新 pip

pip install --upgrade pip --user

直接从 base 复制一个环境,名为 tf20_gpu

conda create --name tf20_gpu --clone base 

然后进入 tf20_gpu 这个环境

conda activate tf20_gpu

安装 gpu 版本的 TensorFlow 2.3.0

pip install tensorflow==2.3.0

安装完成后,可以使用测试代码进行测试环境是否安装成功
cmd 进入python环境,逐行输入下面代码

import tensorflow as tf
print(tf.__version__)
print('GPU', tf.test.is_gpu_available())

如果出现下面错误(感觉98%的可能都会出现,因为目前 tenorflow 貌似没有支持到 cuda10.2的toolkit,2.3.0以下的最高支持 cuda10.1,而目前最新的(截止到文章日期:2021.01.02)的 tensorflow 版本是 2.4.0 支持 cuda 11.0)

 Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found

下面给出 3 个解决方法(我直接用第3个方法):

  1. 重新下载 cuda 10.1 的 toolkit,同时降级显卡驱动,cuda toolkit 安装包其实已经带有驱动了
  2. 更新显卡驱动(必须显卡支持才行)下载最新的 cuda 11.0 toolkit,与 cudnn 8,同时安装tensorflow 2.4.
  3. 将 cudart64_102.dll 复制一份,重命名为 cudart64_101.dll,使得 import tensorflow 时能够找到对应的dll文件。
    在这里插入图片描述
    重新打开 CMD 进行测试
    在这里插入图片描述
    最后出现 GPU True,意味着环境已经安装成功
    在这里插入图片描述

win10 的深度神经网络GPU训练环境搭建到此搭建完毕!

  • 4
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
自编译tensorflow: 1.python3.5,tensorflow1.12; 2.支持cuda10.0,cudnn7.3.1,TensorRT-5.0.2.6-cuda10.0-cudnn7.3; 3.无mkl支持; 软硬件硬件环境:Ubuntu16.04,GeForce GTX 1080 TI 配置信息: hp@dla:~/work/ts_compile/tensorflow$ ./configure WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown". You have bazel 0.19.1 installed. Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3 Found possible Python library paths: /usr/local/lib/python3.5/dist-packages /usr/lib/python3/dist-packages Please input the desired Python library path to use. Default is [/usr/local/lib/python3.5/dist-packages] Do you wish to build TensorFlow with XLA JIT support? [Y/n]: XLA JIT support will be enabled for TensorFlow. Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: No OpenCL SYCL support will be enabled for TensorFlow. Do you wish to build TensorFlow with ROCm support? [y/N]: No ROCm support will be enabled for TensorFlow. Do you wish to build TensorFlow with CUDA support? [y/N]: y CUDA support will be enabled for TensorFlow. Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10.0]: Please specify the location where CUDA 10.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda-10.0 Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]: 7.3.1 Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda-10.0]: Do you wish to build TensorFlow with TensorRT support? [y/N]: y TensorRT support will be enabled for TensorFlow. Please specify the location where TensorRT is installed. [Default is /usr/lib/x86_64-linux-gnu]://home/hp/bin/TensorRT-5.0.2.6-cuda10.0-cudnn7.3/targets/x86_64-linux-gnu Please specify the locally installed NCCL version you want to use. [Default is to use https://github.com/nvidia/nccl]: Please specify a list of comma-separated Cuda compute capabilities you want to build with. You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus. Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 6.1,6.1,6.1]: Do you want to use clang as CUDA compiler? [y/N]: nvcc will be used as CUDA compiler. Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: Do you wish to build TensorFlow with MPI support? [y/N]: No MPI support will be enabled for TensorFlow. Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]: Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: Not configuring the WORKSPACE for Android builds. Preconfigured Bazel build configs. You can use any of the below by adding "--config=" to your build command. See .bazelrc for more details. --config=mkl # Build with MKL support. --config=monolithic # Config for mostly static monolithic build. --config=gdr # Build with GDR support. --config=verbs # Build with libverbs support. --config=ngraph # Build with Intel nGraph support. --config=dynamic_kernels # (Experimental) Build kernels into separate shared objects. Preconfigured Bazel build configs to DISABLE default on features: --config=noaws # Disable AWS S3 filesystem support. --config=nogcp # Disable GCP support. --config=nohdfs # Disable HDFS support. --config=noignite # Disable Apacha Ignite support. --config=nokafka # Disable Apache Kafka support. --config=nonccl # Disable NVIDIA NCCL support. Configuration finished 编译: bazel build --config=opt --verbose_failures //tensorflow/tools/pip_package:build_pip_package 卸载已有tensorflow: hp@dla:~/temp$ sudo pip3 uninstall tensorflow 安装自己编译的成果: hp@dla:~/temp$ sudo pip3 install tensorflow-1.12.0-cp35-cp35m-linux_x86_64.whl

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值