tensorflow-gpu 安装 tensorflow1.12 + CUDA 9.0 + cudnn 7.5 同时安装gpu版本与cpu版本

Win10下TensorFlow-GPU安装指南

现在 windows10 支持 pip install tensorflow-gpu 直接安装

一、安装tensorflow-gpu

但是需要注意:

1、电脑要支持 CUDA(检查自己的GPU看支持到哪个版本,GTX960M支持9.0)

2、需要下载cudnn,这个深度学习加速库,并把cudnn下面每一项放到CUDA对应目录

 

可能出现的问题:

1、找不到DLL的情况

这个问题可能是,你没有把cudnn对应文件正确的放入CUDA/v9.0/xx目录下面。

也可能是你的CUDA与cudnn版本不兼容

还有可能就是你所pip安装的tensorflow和你安装的CUDA版本不兼容(因为pip默认安装当下最新tensorflow,然而他并不一点和你所安装的CUDA版本想兼容,例如我之前安装的tensorflow1.13,他和我安装的CUDA9.0不兼容,所以需要安装tensorflow1.12才行)

2、至于出现了一些警告:

可以不用管,也可以通过忽略解决。

 

二、安装tensorflow -cpu

1、需要另外设置一个虚拟环境进行安装,同时尽量保持 python版本一致,tensorflow版本一致

2、pip安装方式默认安装的是manylinux1_X86这是一个通用版本,在win10上面会有警告。

Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

可直接到http://mirrors.aliyun.com/pypi/simple/tensorflow/下载amd_64版本whl文件安装。

<
自编译tensorflow1.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
<think>好的,我现在需要解决用户提出的关于安装tensorflow-gpu==1.12时找不到匹配版本的问题。首先,我得回顾一下用户提供的引用内容问题描述。用户提到了安装过程中遇到的三个问题,其中第一个是CUDA版本不匹配,需要重新安装。引用[1]指出需要检查TensorFlow官网的版本匹配,引用[2]提供了离线安装包的链接,引用[4]说明了如何离线安装依赖包。 首先,我应该考虑用户可能遇到的问题根源。找不到匹配版本通常有几个原因:Python版本不兼容、CUDAcuDNN版本不匹配,或者pip源中没有对应的旧版本。由于用户指定的是1.12.0版本,这个版本相对较旧,可能不在默认的pip仓库里了,所以用户需要手动下载离线包。 接下来,按照引用[1]的建议,用户需要确认TensorFlow 1.12.0所需的CUDAcuDNN版本。根据我的记忆,TensorFlow 1.12通常需要CUDA 9.0cuDNN 7.1.4。用户需要检查本地环境是否满足这些要求,如果不满足,需要重新安装相应的版本。 然后,用户可能需要从PyPI或其他可靠来源手动下载正确的wheel文件,如引用[2]中的链接所示。但由于版本较旧,可能需要到官方的历史版本页面查找,或者使用第三方镜像源。另外,引用[4]提到的离线安装方法很重要,特别是当用户的电脑无法联网时,需要将所有依赖包下载后依次安装。 还有可能用户尝试使用pip install tensorflow-gpu==1.12.0时,默认的pip源已经移除了这个旧版本,导致找不到包。这时候,用户需要明确指定版本号,或者使用离线安装方式。另外,依赖包的问题也很关键,必须确保所有依赖项如Keras Applications等都已正确安装版本兼容。 用户可能忽略的步骤包括:没有正确配置CUDA环境变量,或者安装了不兼容的Python版本。例如,TensorFlow 1.12.0可能不支持Python 3.7或更高版本,只支持到Python 3.6。所以,用户需要检查Python版本是否符合要求,必要时创建虚拟环境使用Python 3.6。 最后,可能需要建议用户使用Anaconda来管理环境,因为conda可以更方便地处理CUDAcuDNN的依赖关系,自动安装兼容版本。不过,用户提到的是pip安装,所以可能需要指导他们如何通过conda安装,或者坚持使用pip离线安装。 总结解决方案的步骤应该是:1. 确认版本兼容性;2. 下载正确的wheel文件依赖包;3. 离线安装;4. 检查环境变量路径设置。同时,提醒用户注意Python版本依赖项的顺序安装。</think>### 分步解决方案 要解决安装`tensorflow-gpu==1.12`时找不到匹配版本的问题,需依次检查版本兼容性、依赖项安装方式: 1. **确认版本匹配** 根据TensorFlow官方文档[^1],`tensorflow-gpu 1.12.0`要求: - **Python 3.5–3.6**(不支持Python 3.7+- **CUDA 9.0** - **cuDNN 7.1.4** 若版本不匹配,需卸载现有CUDA/cuDNN并重新安装指定版本。 2. **手动下载离线包** 从PyPI历史版本页面下载对应系统的wheel文件[^2]: - Windows: `tensorflow_gpu-1.12.0-cp36-cp36m-win_amd64.whl` - Linux: `tensorflow_gpu-1.12.0-cp36-cp36m-manylinux1_x86_64.whl` 若默认pip源无此版本,可尝试从第三方镜像站(如清华源)下载。 3. **离线安装依赖项** 按顺序安装所有依赖包[^4]: ```bash pip install numpy>=1.13.3 pip install six>=1.11.0 pip install keras-applications==1.0.6 # 需TensorFlow 1.12兼容 pip install keras-preprocessing==1.0.5 pip install grpcio>=1.8.6 pip install absl-py>=0.1.6 pip install tensorflow-estimator==1.12.0 # 必须匹配版本 ``` 最后安装TensorFlow-GPU: ```bash pip install tensorflow_gpu-1.12.0-cp36-cp36m-win_amd64.whl ``` 4. **使用Anaconda环境(推荐)** 若环境复杂,可通过Anaconda隔离Python 3.6环境并自动安装CUDA依赖: ```bash conda create -n tf1.12 python=3.6 conda activate tf1.12 conda install cudatoolkit=9.0 cudnn=7.1.4 pip install tensorflow-gpu==1.12.0 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值