window10环境下tensorflow-gpu-2.7.0安装

window10环境下tensorflow-gpu-2.7.0安装:cuda11.1 + cudnn8.1.1 + pycharm2020.3.5 + anaconda2021.11

pycharm2020.3.5

下载链接: pytcharm官网.

anaconda2021.11

下载链接: anaconda清华大学镜像站.
下载链接: anaconda官网.

cuda

下载链接: CUDA Toolkit 11.1.1下载.
在这里插入图片描述
在这里插入图片描述
安装完毕,环境变量自动添加。

cudnn

下载链接: Download cuDNN v8.1.1 (Feburary 26th, 2021), for CUDA 11.0,11.1 and 11.2.
下载完解压后,将三个文件夹bin,include,lib复制到上一步cuda11安装目录

tensorflow-gpu-2.7.0

pip install tensorflow-gpu -i https://pypi.douban.com/simple

测试

测试一

import tensorflow as tf
print(tf.test.is_gpu_available())

测试二

#测试TensorFlow是否安装GPU支持
import ctypes
import importlib
import sys


def main():
    try:
        import tensorflow as tf
        print("TensorFlow成功安装。")
        if tf.test.is_built_with_cuda():
            print("安装版本的TensorFlow包括GPU支持。")
        else:
            print("安装版本的TensorFlow不包括GPU支持。")
        sys.exit(0)
    except ImportError:
        print("ERROR: Failed to import the TensorFlow module.")
    candidate_explanation = False
    python_version = sys.version_info.major, sys.version_info.minor
    print("\n- Python version is %d.%d." % python_version)
    if not (python_version == (3, 5) or python_version == (3, 6)):
        candidate_explanation = True
        print("Windows的官方发布版本需要Python版本3.5或3.6。")
    try:
        _, pathname, _ = importlib.find_module("tensorflow")
        print("\n- TensorFlow is installed at: %s" % pathname)
    except ImportError:
        candidate_explanation = False
        print("tensorflow")
    try:
        msvcp140 = ctypes.WinDLL("msvcp140.dll")
    except OSError:
        candidate_explanation = True
        print("msvcp140.dll")
    try:
        cudart64_80 = ctypes.WinDLL("cudart64_80.dll")
    except OSError:
        candidate_explanation = True
        print("cudart64_80.dll")
    try:
        nvcuda = ctypes.WinDLL("nvcuda.dll")
    except OSError:
        candidate_explanation = True
        print("nvcuda.dll")
    cudnn5_found = False
    try:
        cudnn5 = ctypes.WinDLL("cudnn64_5.dll")
        cudnn5_found = True
    except OSError:
        candidate_explanation = True
        print("cudnn64_5.dll")
    cudnn6_found = False
    try:
        cudnn = ctypes.WinDLL("cudnn64_6.dll")
        cudnn6_found = True
    except OSError:
        candidate_explanation = True
    if not cudnn5_found or not cudnn6_found:
        print()
        if not cudnn5_found and not cudnn6_found:
            print("- Could not find cuDNN.")
        elif not cudnn5_found:
            print("- Could not find cuDNN 5.1.")
        else:
            print("- Could not find cuDNN 6.")
            print("99-109")
    if not candidate_explanation:
            print("112-114")
    sys.exit(-1)
if __name__ == "__main__":
    main()

另:一些说明
1、本博客仅用于学习交流,欢迎大家瞧瞧看看,为了方便大家学习,相关论文请去知网等地方自行下载。
2、如果原作者认为侵权,请及时联系我,我的qq是1294865211,邮箱是1294865211@qq.com,我会及时删除侵权文章。
3、我的文章大家如果觉得对您有帮助或者您喜欢,请您在转载的时候请注明来源,不管是我的还是其他原作者,我希望这些有用的文章的作者能被大家记住。
4、最后希望大家多多的交流,提高自己,从而对社会和自己创造更大的价值。

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值