CUDA安装 + tensorflow gpu版本出现的问题:Not creating XLA devices, tf_xla_enable_xla_devices not set
装完后用以下两行代码测试,结果竟然是False,输出了图片中的报错,肯定是哪装的有问题
import tensorflow as tf
tf.test.is_gpu_available()
我的tensorflow版本:
我的cuda版本:cuda_11.1.1_456.81_win10
我的cudnn版本:cuDNN v8.0.4 (September 28th, 2020), for CUDA 11.1
cuda下载地址: https://developer.nvidia.com/cuda-toolkit-archive
cudnn下载地址:(需要注册登录才能下)https://developer.nvidia.com/rdp/cudnn-archive
我觉得版本对应上应该是没有问题的。
但是网上搜了一阵子后,我开始怀疑是不是版本有问题了,然后我找了一个版本对应关系,猜测我这个可能不适合安装cuda11
然后我就把cuda卸了(控制面板卸载,再把之前的安装文件夹删了),重装了cuda10.1和cudnn8再改了环境变量,发现在导入tensorflow时又报如下错误:
In [1]: import tensorflow as tf
2021-01-13 16:02:54.399456: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-01-13 16:02:54.399792: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
依提示来看我应该用cuda11来着,但是刚才装的11就没弄好,我也不知道tensorflow2.4应该对应哪个版本的cuda,于是我又重新装了tensorflow2.3,
tensorflow和cuda版本的对应关系: https://tensorflow.google.cn/install/source_windows#tensorflow_2x
这下再导入tf,结果如下:
In [1]: import tensorflow as tf
2021-01-13 16:17:24.786482: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2021-01-13 16:17:24.786734: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
说明cuda版本装10.1应该是没问题的,但是我在对应目录下能找到cudart64_101.dll,环境变量也是对的,这就很奇怪,然后重启了一下发现tf能导入了,但测试的时候又了出来了新的错误:
Could not load dynamic library 'cudnn64_7.dll'; dlerror: cudnn64_7.dll not found
2021-01-13 16:24:42.757869: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
2021-01-13 16:24:42.858065: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-01-13 16:24:42.858269: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263] 0
2021-01-13 16:24:42.859765: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 0: N
2021-01-13 16:24:42.868797: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1954aacca00 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2021-01-13 16:24:42.868991: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): GeForce 920M, Compute Capability 3.5
因为我装的cudnn版本是 cuDNN v8.0.4 (September 28th, 2020), for CUDA 10.1,所以报这个错倒也能理解,于是我又重新下了cuDNN v7.6.5 (November 5th, 2019), for CUDA 10.1,复制过去后再重新运行tf.test.is_gpu_available()
这下终于提示True了。
但是偶尔它会提示以下错误,不知道是咋回事:
In [3]: tf.test.is_gpu_available()
2021-01-13 16:37:43.104996: F tensorflow/stream_executor/lib/statusor.cc:34] Attempting to fetch value instead of handling error Internal: failed to get device attribute 13 for device 0: CUDA_ERROR_UNKNOWN: unknown error
问题解决!
这东西竟然又花了我一天时间,这个版本对应问题真的是好麻烦。
环境变量
因为在自定义安装的时候只需要安装CUDA
,其它几个可以不装,所以一共用这3个环境变量
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\CUPTI\lib64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\cudnn\bin
从这环境变量可以看出我的cudnn复制到了v10.1目录下,这个cudnn名字好像可以取其它的
借鉴了这两篇博客:
安装TensorFlow-gpu 2.2的详细教程:血泪巨坑(包教包会)
tensorflow GPU测试tf.test.is_gpu_avaiable()返回false解决方法
测试
安装好后可以测试一下,在终端输入这个nvcc -V
就可以看到cuda版本
或者在系统环境变量里的path中加入这一个C:\Program Files\NVIDIA Corporation\NVSMI\
,就可以在终端中输入nvidia-smi
可以看到显卡驱动版本、cuda版本、显卡使用情况
最后可以用如下代码检测一下gpu加速的效果(我的920M竟然还是有些效果)
import tensorflow as tf
import timeitwith tf.device('/cpu:0'):cpu_a = tf.random.normal([10000, 1000])cpu_b = tf.random.normal([1000, 2000])print(cpu_a.device, cpu_b.device)with tf.device('/gpu:0'):gpu_a = tf.random.normal([10000, 1000])gpu_b = tf.random.normal([1000, 2000])print(gpu_a.device, gpu_b.device)def cpu_run():with tf.device('/cpu:0'):c = tf.matmul(cpu_a, cpu_b)return cdef gpu_run():with tf.device('/gpu:0'):c = tf.matmul(gpu_a, gpu_b)return c# warm up 这里就当是先给gpu热热身了
cpu_time = timeit.timeit(cpu_run, number=10)
gpu_time = timeit.timeit(gpu_run, number=10)
print('warmup:', cpu_time, gpu_time)cpu_time = timeit.timeit(cpu_run, number=10)
gpu_time = timeit.timeit(gpu_run, number=10)
print('run time:', cpu_time, gpu_time)
运行结果:
...
warmup: 3.0217729 0.33188580000000023
run time: 2.979343599999999 0.000807700000001077
CUDA安装 + tensorflow gpu版本出现的问题:Not creating XLA devices, tf_xla_enable_xla_devices not set相关推荐
- 安装Tensorflow 报错false Not creating XLA devices, tf_xla_enable_xla_devices not set
学习图像识别配置环境 https://blog.csdn.net/weixin_44170512/article/details/103990592 一步一步按照博主配置 执行到这两句 import ...
- tensorflow:Not creating XLA devices, tf_xla_enable_xla_devices not set
运行代码出现 I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_d ...
- windows10下安装tensorflow(gpu版本)
windows10安装tensorflow的gpu版本(pip3安装方式) 前言: TensorFlow 有cpu和 gpu两个版本:gpu版本需要英伟达CUDA 和 cuDNN 的支持,cpu版本不 ...
- Ubuntu 20.04 安装Tensorflow GPU版本 (GTX-1060显卡)
Ubuntu 20.04 安装Tensorflow GPU版本 (GTX-1060显卡) 参考: https://cyfeng.science/2020/05/02/ubuntu-install-nv ...
- 彻底解决conda环境下 tensorflow gpu版本出现的问题:Not creating XLA devices, tf_xla_enable_xla_devices not set
问题说明 tf.test.is_gpu_available()结果为TRUE,但有Not creating XLA devices, tf_xla_enable_xla_devices not set ...
- Linux conda tensorflow-gpu安装及Not creating XLA devices, tf_xla_enable_xla_devices not set相关问题解决
0.首先介绍一下conda创建虚拟环境的基本操作. (1)创建Python的虚拟环境,并指定Python版本,不指定的话会使用默认的版本(Conda Base 环境中的Python版本). conda ...
- win10系统tensorflow2.4.0-gpu安装“Not creating XLA devices, tf_xla_enable_xla_devices not set”解决方法
未解决前报错 最近在安装tensorflow2.4.0-gpu版本后的项目开发过程中出现了"Not creating XLA devices, tf_xla_enable_xla_dev ...
- 通过Anaconda在Ubuntu16.04上安装 TensorFlow(GPU版本)
一. 安装环境 Ubuntu16.04.3 LST GPU: GeForce GTX1070 Python: 3.5 CUDA Toolkit 8.0 GA1 (Sept 2016) cuDNN v6 ...
- win7 64位 安装tensorflow GPU版本
近日终于在win7上安装成功tensorflow GPU版本,并测试成功!这里将其中遇到的种种问题和解决方法做下记录,以供大家相互交流! 电脑配置:16G内存:处理器: AMD Athlon(tm ...
最新文章
- spark数据查询语句select_sparksql语句
- 英雄会被表彰,这些技术与代码也将被历史铭记
- sonarqube使用mysql_SonarQube的安装、配置与使用
- javascript-引入-函数的定义与使用-多值传参-ao对象
- vscode用作markdown入门1--环境创建
- 申请AppleID的界面,连继续按钮都看不到
- 计算机组成原理 学后感,【计算机组成原理实验心得体会】_计算机组成原理实验心得_计算机组成原理实验感想...
- 安装GitExtentions KDiff3已配置为合并工具,kdiff3的路径未配置
- 《一切都是最好的安排》——加措
- K8S 创建 Deployment
- 机器学习Machine Learning
- 适合大学生用的网课作业搜题找答案的神器分享~~
- SpringCloud微服务,euraka、feign、hystrix组件学习
- 计算机配置xp系统,教你WinXP系统如何设置一台电脑两个显示器
- web结课作业的源码——HTML+CSS+JavaScript仿oppo官网手机商城(1页)
- ARM核心板有哪些不同之处?
- 2020百度大数据竞赛-Top3 故事分享(开源连接)新手入门
- 代码要写成别人看不懂的样子(二十六)
- 全网热议的OPPO X 2021卷轴屏概念机是如何诞生的?
- ftp协议及简单配置