美文网首页
Tensorflow2.2的安装教程

Tensorflow2.2的安装教程

作者: dillqq | 来源:发表于2021-07-22 11:46 被阅读0次
    conda create -n dl python=3.7
    conda activate dl
    conda install cudatoolkit=10.1 cudnn=7.6.5
    #tensorflow的安装也方便没啥警告
    pip install tensorflow-gpu -i https://pypi.douban.com/simple
    #到目前(2020年5月7日)最新的pytorch gpu版本也可以安装
    pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.douban.com/simple
    

    测试是否安装成功
    方法一

    import tensorflow as tf 
    print(tf.__version__)
    #输出'2.0.0-alpha0'
    print(tf.test.is_gpu_available())
    #会输出True,则证明安装成功
    

    方法二

    # 输入python,进入python环境
    import tensorflow as tf
    #查看tensorflow版本
    print(tf.__version__)
    #输出'2.0.0-alpha0'
    #测试GPU能否调用,先查看显卡使用情况
    import os 
    os.system("nvidia-smi")
    #调用显卡
    @tf.function
    def f():
        pass
    f()
    #这时会打印好多日志,我电脑上还有warning,感觉不影响
    #再次查询显卡
    os.system("nvidia-smi")
    

    参考:https://blog.csdn.net/u011119817/article/details/88309256

    相关文章

      网友评论

          本文标题:Tensorflow2.2的安装教程

          本文链接:https://www.haomeiwen.com/subject/fememltx.html