TensorFlow安装-(Ubuntu18.04.3 & Anaconda3)

1、背景

  使用ubuntu18.04.3安装Anaconda3之后使用网上教程安装tensorflow失败,踩了多个坑,特此总结经验

  附官方教程:https://tensorflow.google.cn/install/pip

2、踩坑过程

  1)坑1:按照官网说明在升级pip3后在终端输入命令: 

    pip3 install --user --upgrade tensorflow

    会出现以下错误:

    Cache entry deserialization failed, entry ignored
       Could not find a version that satisfies the requirement tensorflow (from versions: )
    No matching distribution found for tensorflow
    相关资料提供解决方案:https://blog.csdn.net/u013421629/article/details/102857396

    结果:无效。

  2)在终端直接下载tensorflow,命令为

    pip install --upgrade tensorflow或pip install tensorflow

    现象:会根据系统anaconda中对应的python版本下载对应的tensorflow,但下载速度非常慢,一段时间后Read timed out错误.
    相关资料解决方案:https://blog.csdn.net/abcabc77777/article/details/53456453?utm_source=distribute.pc_relevant.none-task

    结果:无效,依旧会报错。

    原因:被墙了

    解决方案:使用国内镜像,参考:https://blog.csdn.net/Mundane_World/article/details/81636609?utm_source=distribute.pc_relevant.none-task

    3)在仓库寻找所需tensorflow版本,下载安装包,地址:https://pypi.org/project/tensorflow/#files

      然后将下载后的.whl文件移动到/home/your name/anaconda3/bin/目录下(your name是用户名),打开终端,输入命令:

       pip --default-timeout=1000 install tensorflow-2.1.0-cp36-cp36m-manylinux2010_x86_64.whl

      安装对应版本的tensorflow(注:tensorflow只有64系统的版本)

     现象:终端上会下载其他相关的包,所占内存很小,但下载速度极慢,仍旧出现Read timed out错误。

     结果:无效,完全下载(亲测两天时间都没下载成功)

3、解决方案:

  在终端输入命令:

    conda install keras

安装keras过程中,会自动暗转所需的TensorFlow

4、结论

  以上解决方案中的命令成功的前提是anaconda3环境都成功配置,打开在终端输入命令

    spyder或jupyter notebook

  可以成功打开IDE,打开后测试:

    import tensorflow as tf

    hello = tf.constant('hello world shilongejie')

    sess = tf.Session()

    print(sess.run(hello))

  以上代码在IDE中不会报错并成功运行,到此配置成功!


 

猜你喜欢

转载自www.cnblogs.com/longjie-shi/p/12323566.html