win10系统CUDA10.0安装教程(for tensorflow2.0)

  前言:目前最新的CUDA版本是10.1,但是出于某种神秘的原因,目前tensorflow2.0仅支持CUDA10.0。这个已经在我的电脑与一部分网友的反馈中得到了证实。tensorflow2.0不仅绑定了CUDA的版本,还对CUDA安装配置有一定要求。为了实现GPU加速,这里将安装与配置过程记录一下。

下载并安装CUDA10.0

  献上各种CUDA的下载链接:https://developer.nvidia.com/cuda-toolkit-archive
  由于我们必须要CUDA10.0,因此选择版本的时候一定要选择CUDA Toolkit 10.0,注意是10.0,不能是10.1。
在这里插入图片描述
  如上图所示,根据自己电脑的系统型号和位数选择合适的版本,然后下载即可。一共是2G多,但是英伟达的服务器不错,下载速度还是比较快的。
在这里插入图片描述
  下载下来是上图这个样子,这其实是个解压缩程序。最好自己先提前建个文件夹,把解压完的安装程序搁里面。
在这里插入图片描述
  如上图所示,我新建了个文件夹cuda10.0,运行安装程序将其路径导入。
在这里插入图片描述
  当解压完毕后会自动运行安装程序,上图的窗口会自动弹出来,点击同意并继续
在这里插入图片描述
  接下来一定要讲究了,不然容易翻车!如上图所示,一定要选择自定义安装
在这里插入图片描述
  讲究第一步:尽量将组件中的NVDIA GeForce Experience选项勾掉。有的人可能认识这个,这不调游戏画面参数的那个嘛。咳咳,这个是NVDIA提供给用户的一个类似于控制面板的东西,但是目前电脑装机一般都给安装了;而且就算是没有,这个东西对我们显卡加速程序是没有帮助的。
在这里插入图片描述
  讲究第二步:在组件CUDA中将Visual Studio Intergration取消掉。这个还是蛮有意思的,因为这个组件是专为VS配置的,但是现在使用的代码编译器基本都是vscode,pycharm等轻量编译器之流,用VS就比较没意义了;我在网上还看见一个说法,这个必须取消掉,不然没法正确安装。反正取消就完事了。
在这里插入图片描述
  讲究第三步:CUDA在安装的时候会默认安装一个NVDIA的显卡驱动。上图可以看出,该显卡驱动版本是411.31。划重点:“当前版本”这一栏会显示你目前电脑上的显卡驱动型号,比如上图所示,我的电脑目前驱动是430.86,这个数字大于411.31,说明版本更新一些。如果你的当前版本高于CUDA想要安装的新版本,那么一定要把display driver取消掉!不然CUDA安装发现你现有的比我要安的还高级,我还安个锤子,就会出现安装失败的错误;如果你的当前版本低于CUDA想要安装的新版本,那么一定要把display driver勾选,驱动版本不够新,CUDA也运行不了。如果巧了当前版本与新版本一模一样,那勾不勾选随意

在这里插入图片描述
  OK安装好了,我们去上图所示的路径检查nvcc.exe是否存在,这个程序很重要。
在这里插入图片描述
  再从上图的路径中检查这个动态库是否存在,这个动态库也很重要。

安装cudnn:

  先献上网址:https://developer.nvidia.com/rdp/cudnn-archive

在这里插入图片描述
  如上图所示,要选择for CUDA 10.0的版本
在这里插入图片描述
  然后选择适合自己系统的版本。
在这里插入图片描述
  下载下来是个压缩包,解压完如上图所示,名字叫cuda,里面有三个文件夹。我们需要把它的名字从cuda改成cudnn,没错,就是重命名。
在这里插入图片描述
  OK,把文件夹改名之后按照上图所示把它直接复制粘贴到上图的路径中就好了。
在这里插入图片描述
  这里稍微检查一下,cudnn64_7.dll这个动态链接库存在不,这个库也很重要。

环境变量配置

在这里插入图片描述
  开始配置环境变量!右键点击“我的电脑”,选择“属性”,选择“高级系统设置”,接下来的窗口如上图所示。接下来选择“系统变量”里面的Path,点击“编辑”。
在这里插入图片描述
  如上图所示,因为CUDA已经安好了,所以这里的路径已经添加了两个关于CUDA的。但是还不够,我们还需要添加两个。
在这里插入图片描述
  新建环境变量的方法很简单,点击新建,再点击浏览。按照上图所示,将CUPTI\libx64路径导入。同理再新建一个将cudnn\bin路径导入。
在这里插入图片描述
  导入以后我们需要点击上移,把四个关于CUDA的环境变量路径置顶,至于这四个的顺序倒是没什么关系。点击确定后退出即可。
在这里插入图片描述
  打开命令行工具,输入 nvcc -V。如上图所示,就是配置成功了。
在这里插入图片描述
  安装好tensorflow2.0之后可以按照上图的命令语句输入,看到结果如上图所示就是完全OK了。

自编译tensorflow: 1.python3.5,tensorflow1.12; 2.支持cuda10.0,cudnn7.3.1,TensorRT-5.0.2.6-cuda10.0-cudnn7.3; 3.支持mkl,无MPI; 软硬件硬件环境:Ubuntu16.04,GeForce GTX 1080 配置信息: 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 编译: hp@dla:~/work/ts_compile/tensorflow$ bazel build --config=opt --config=mkl --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
评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值