win10+RTX2060+CUDA10.0+cuDNN7.6.5+TensorFlow1.14.0安装(踩坑过程)

之前已经安装好了TensorFlow,配置是Anaconda(python3.6.5)+VS2015 +CUDA9.2 +cuDNN7.2.1.38 + TensorFlow1.10.0 。但是有一次使用Anaconda中的jupyter notebook时出现了一些问题。就是运行程序是,一直是In[*]的状态,哪怕是运行简单的print(123)也是这种状态,我尝试了各种方法,包括先卸载jupyter和notebook,然后再重新pip install jupyter和note;甚至卸载并重装了Anaconda,以及尝试了不同版本的Anaconda,最终都没有得到解决。于是乎,我决定重装整个这一套,踩坑无数,花了周末一整天的时间,终于搞定。

这次我配置的是:Anaconda(python3.7.3)+VS2017(社区版)+CUDA10.0+cuDNN7.6.5+TensorFlow1.14.0

1. Anaconda的安装

Anaconda中有很多工具包,省去了很多麻烦,这里不再赘述Anaconda的强大之处了。我这次安装采用的Anaconda-2019.07.(python3.7.3),由于官网上的是最新的Anaconda,且旧版本在官网比较难找,于是我贴上了Anaconda的安装包。

链接:https://pan.baidu.com/s/1kKHOM8gyOBgfBmmOhfs78A 
提取码:5tti

对于Anaconda就采取傻瓜式安装即可,唯一需要注意的一点是,在设置安装路径的后一步骤,有两个勾选项,一个是将路径天剑到环境变量,另一个是安装python3.7,记得把这两个勾选项都选上就行。                        

2. VS2017(社区版)

现在VS官网主推的是2019版本,所以2017版本也不是很好找,所以我同样附上了安装包。

链接:https://pan.baidu.com/s/1m7N1A7HMZdbTVJ22UhkEUg 
提取码:jm3o 
这个也采用傻瓜式安装即可,安装过程中,把.NET和C++开发都勾选上,安装大小大约为7.5G左右。如下图:                                       

3. CUDA10.0的安装

首先看看自己的电脑是不是支持CUDA10.0,步骤:桌面右键--->NVIDIA控制面板--->帮助--->系统信息--->组件,会得到如下图:

                              

可以看到,我的电脑最高支持CUDA10.2.95所以安装CUDA10.0是没有问题的。下面直接在官网下载CUDA10.0即可:

        

Installer Type既可以选择network也可以选择local,network比较小,类似于下载器,运行时边下载边安装;而local相当于下载好的安装包,安装时间较短。下载完后,进行傻瓜式安装即可(不建议修改安装路径,默认路径为:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0)。

4. cuDNN的下载

cuDNN直接去官网下载即可,下载cuDNN时需要登录账号,不过可以微信登录,这就省去了注册的麻烦,一定要下载与CUDA版本对应的cuDNN

                      

cuDNN是一个压缩文件,将其解压,然后解压后的文件夹下的3个文件夹和1个文件copy到CUDA的安装路径下,即:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0

                 

为了检验CUDA是否安装成功,cmd打开命令窗口,输入:nvcc -V,如下:

                           

可以看到CUDA10.0.13已经安装成功。所有的准备工作都已做好,接下来就是安装TensorFlow1.14.0了。

5. TensorFlow1.14.0的安装

看了大量的博客,采用较多的是使用这篇GitHub中的安装包,它里面有个完整的版本对应表(但是我按照这个对应表安装Anaconda(python3.7)+VS2017+CUDA10.1+cuDNN(7.5)+TensorFlow1.13.1,并没有成功,所以我没有使用其中的安装包)。

我没有参照这篇GitHub,而是参照了TensorFlow官网的安装,直接在Anaconda prompt中输入了以下命令:                      

conda install tendorflow-gpu==1.14

建议使用conda安装,不要使用pip,不然import tensorflow时容易报错:ImportError:DLL:找不到对应模块。

最后,我们测试一下:

      

红框中可以看到,程序是使用GPU运行的,至此,tensorflow安装(踩坑)完成。

总结:

GPU下安装TensorFlow主要就是各种版本对应问题,一个版本不对应,全盘皆错,很难排查出问题,所以还是建议按照网上别人的教程来安装,毕竟教程中成功的安装需要的各个安装包的版本都是确定的,按照教程的安装版本来可以避免少踩很多坑。

自编译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
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值