Linux conda tensorflow-gpu安装及Not creating XLA devices, tf_xla_enable_xla_devices not set相关问题解决

0、首先介绍一下conda创建虚拟环境的基本操作。
(1)创建Python的虚拟环境,并指定Python版本,不指定的话会使用默认的版本(Conda Base 环境中的Python版本)。

conda create -n grape python=3.8.8   # grape可以指定为自己想要的名字

(2)进入创建好的虚拟环境。

conda activate grape

(3)退出当前Anaconda虚拟环境,在当前环境中执行以下指令。

conda deactivate

(4)删除这个虚拟环境

conda remove -n grape --all

出现 Not creating XLA devices, tf_xla_enable_xla_devices not set问题,一般是由于tensorflow和cuda、cuddn的版本问题。建议直接花几分钟重新配置环境,以下有两种方法安装tensorflow。

1、直接用conda create一个相应版本的tensorflow-gpu虚拟环境。

conda create -n tf tensorflow-gpu==2.2.0

在安装过程中会自己安装相应的cuda、cuddn包。

Linux conda tensorflow-gpu安装及Not creating XLA devices, tf_xla_enable_xla_devices not set相关问题解决

2、安装需要的cuda和cudnn环境,再安装tensorflow-gpu。
首先我们需要确定我们需要的tensorflow-gpu的版本,再在tensorflow找到对应的cuda和cudnn版本。网上部分帖子里面的不太对,还是自己去官网看比较靠谱。
https://tensorflow.google.cn/install/source#install_the_package

Linux conda tensorflow-gpu安装及Not creating XLA devices, tf_xla_enable_xla_devices not set相关问题解决
以tensorflow-gpu-2.2.0为例。
(1)首先创建一个python虚拟环境并激活
conda create -n grape python=3.8.8
conda activate grape

(2)在环境中安装cuda

conda install cudatoolkit=10.1 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/

(3)在环境中安装cudnn

conda install cudnn=7.6.5 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/

(4)安装tensorflow-gpu-2.2.0

conda install tensorflow-gpu-2.2.0

有问题欢迎留言交流。

Original: https://blog.csdn.net/qq_39245082/article/details/122117167
Author: alpsilon
Title: Linux conda tensorflow-gpu安装及Not creating XLA devices, tf_xla_enable_xla_devices not set相关问题解决

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/771366/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球