欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

新手Tensorflow安装踩坑实录

程序员文章站 2022-06-16 21:19:34
...

@[TOC]Tensorflow安装踩坑实录

环境配置

Win10+python3.7+CUDA10.0+CUDN10.0+tensorflow2.1+anaconda5.3.1
附上详细文件名和版本号:
cuda_10.0.130_win10_network
cudnn-10.0-windows10-x64-v7.6.5.32
tensorflow-2.1.0-cp37-cp37m-win_amd64.whl
Anaconda3-5.3.1-Windows-x86_64

问题

因为毕设课题为基于Deeplearning来降低HEVC帧内编码复杂度,需要运用到tensorflow,安装过程中,遇到了很多问题,查了几十篇帖子,花了整整三天时间才终于可以成功import tensorflow,简直泪奔,第一写篇帖子,简单记录一下自己的几个问题。

一、 安装CPU还是GPU版

现在基本笔记本都能安装GPU版本,确认你的GPU是不是NVIDIA即可,具体的显卡型号配置可以查阅官网。(https://developer.nvidia.com/cuda-gpus)新手Tensorflow安装踩坑实录

二、 版本匹配

很多帖子都有说明,因为我的python为3.7,但是这些都是针对3.6及以下版本的,也记录在这里,(https://blog.csdn.net/qq_27825451/article/details/89082978)

三、tensorflow安装

很多帖子是直接pip安装,可是我试了很多次,不仅安装时间过长,而且试了不同方法,依旧报各种错,最终尝试通过下载whl安装成功。

1.下载地址(https://pypi.org/project/tensorflow/#files)
新手Tensorflow安装踩坑实录
因为我是3.7版本,所以下载cp37。

2.安装
打开控制台cmd,cd进入你下载的 tensorflow-1.13.1-cp37-cp37m-win_amd64.whl 文件的位置
输入 pip install tensorflow-1.13.1-cp37-cp37m-win_amd64.whl

3.问题描述:
安装过程中,出现错误提示(setuptools 版本太旧 , wrapt 不能卸载):

tensorboard 1.14.0 has requirement setuptools>=41.0.0, but you'll have setuptools 40.6.3 which is incompatible.

Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall

4.解决方法:
参考(https://blog.csdn.net/weixin_42419002/article/details/100665921)当安装过程出现异常提示时,需要强制安装时,使用如下命令:

 pip install --ignore-installed  <库名>

按照错误提示,一步步安装:
①更新 wrapt

pip install --ignore-installed wrapt

②更新 setuptools

pip install --ignore-installed  setuptools

③安装tensorflow

pip install tensorflow

四、找不到指定模块

1.问题描述
安装完成之后,在cmd中import tensorflow时报错:

ImportError: DLL load failed: 找不到指定的模块

新手Tensorflow安装踩坑实录
2.解决方法:
参考了(https://blog.csdn.net/qq_41895190/article/details/83892505?depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-14&utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-14)

新手Tensorflow安装踩坑实录
在https://visualstudio.microsoft.com/zh-hans/downloads/?rr=https%3A%2F%2Fsocial.msdn.microsoft.com%2FForums%2Fvstudio%2Fen-US%2Fe653a57a-bc32-4134-87bf-df33058f0531%2Fdownload-microsoft-visual-c-2017-redistributable%3Fforum%3Dvssetup 下载这个工具,安装之后,错误消失,import tensorflow成功。

五、一些其他问题
1.由于刚开始不清楚版本要求,安装错CUDA之后我自己在添加程序中卸载的,然后重新安装时一直报脚本错误,无法安装,后来查到了DDU显卡卸载工具,来卸载干净
新手Tensorflow安装踩坑实录
下载地址(https://www.7down.com/soft/94351.html)

  1. 尝试卸载老版本之后安装anaconda官网最新版,但是安装之后,cmd命令行中conda -V出错,并且conda文件夹丢失大量文件, 不知道是不是卸载不干净的问题,一直解决不了,重新安装3.5版本之后就好了。