找不到 TensorFlow libdevice。为什么在搜索路径中没有找到?
TensorFlow libdevice not found. Why is it not found in the searched path?
Win 10 64位21H1; TF2.5, CUDA 11 安装环境 (Python 3.9.5 Xeus)
我不是唯一看到此错误的人;另见(未答复)here and here。
问题不明确,建议的解决方案 unclear/don 似乎不起作用(参见 here)
问题使用TFLinear_Mixed_Effects_Models.ipynb示例(从TensorFlow下载githubhere)执行达到执行“预热”的程度阶段”然后抛出错误:
InternalError: libdevice not found at ./libdevice.10.bc [Op:__inference_one_e_step_2806]
控制台包含此输出,表明它找到了 GPU,但 XLA 初始化未能找到 - 现有! - 指定路径中的 libdevice
2021-08-01 22:04:36.691300: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1418] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 9623 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
2021-08-01 22:04:37.080007: W tensorflow/python/util/util.cc:348] Sets are not currently considered sequences, but this may change in the future, so consider avoiding using them.
2021-08-01 22:04:54.122528: I tensorflow/compiler/xla/service/service.cc:169] XLA service 0x1d724940130 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2021-08-01 22:04:54.127766: I tensorflow/compiler/xla/service/service.cc:177] StreamExecutor device (0): NVIDIA GeForce GTX 1080 Ti, Compute Capability 6.1
2021-08-01 22:04:54.215072: W tensorflow/compiler/tf2xla/kernels/random_ops.cc:241] Warning: Using tf.random.uniform with XLA compilation will ignore seeds; consider using tf.random.stateless_uniform instead if reproducible behavior is desired.
2021-08-01 22:04:55.506464: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:73] Can't find libdevice directory ${CUDA_DIR}/nvvm/libdevice. This may result in compilation or runtime failures, if the program we try to run uses routines from libdevice.
2021-08-01 22:04:55.512876: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:74] Searched for CUDA in the following directories:
2021-08-01 22:04:55.517387: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] C:/Users/Julian/anaconda3/envs/TF250_PY395_xeus/Library/bin
2021-08-01 22:04:55.520773: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2
2021-08-01 22:04:55.524125: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] .
2021-08-01 22:04:55.526349: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:79] You can choose the search directory by setting xla_gpu_cuda_data_dir in HloModule's DebugOptions. For most apps, setting the environment variable XLA_FLAGS=--xla_gpu_cuda_data_dir=/path/to/cuda will work.
现在有趣的是,搜索到的路径包括“C:/Users/Julian/anaconda3/envs/TF250_PY395_xeus/Library/bin”
该文件夹的内容包括所有(在 TF 启动时成功加载的)DLL,包括 cudart64_110.dll、dudnn64_8.dll... 当然还有 libdevice.10.bc
问题既然 TF 说它正在搜索这个文件的这个位置并且文件存在于那里,那么问题是什么,我该如何解决?
(注意 C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2
不存在...环境中安装了 CUDA;此路径必须是 OS 安装的最佳猜测)
信息:我通过
设置路径
aPath = '--xla_gpu_cuda_data_dir=C:/Users/Julian/anaconda3/envs/TF250_PY395_xeus/Library/bin'
print(aPath)
os.environ['XLA_FLAGS'] = aPath
但我还设置了一个 OS 环境变量 XLA_FLAGS 为相同的字符串值...我不知道哪个在实际工作,但控制台输出的事实说它搜索了预期的路径就足够了
诊断信息不明确,无帮助;但是有一个决议
通过在此路径提供文件(作为副本)解决了问题
C:\Users\Julian\anaconda3\envs\TF250_PY395_xeus\Library\bin\nvvm\libdevice\
请注意 C:\Users\Julian\anaconda3\envs\TF250_PY395_xeus\Library\bin
是给 XLA_FLAGS 的路径,但它似乎不是在寻找 libdevice file 而是在寻找\nvvm\libdevice\ path 这意味着我不能在 XLA_FLAGS 中设置一个不同的值来指向 libdevice 文件的实际位置,因为,短语,它不(只是)它正在寻找的文件。
之前的调试信息:
2021-08-05 08:38:52.889213: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:73] Can't find libdevice directory ${CUDA_DIR}/nvvm/libdevice. This may result in compilation or runtime failures, if the program we try to run uses routines from libdevice.
2021-08-05 08:38:52.896033: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:74] Searched for CUDA in the following directories:
2021-08-05 08:38:52.899128: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] C:/Users/Julian/anaconda3/envs/TF250_PY395_xeus/Library/bin
2021-08-05 08:38:52.902510: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2
2021-08-05 08:38:52.905815: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] .
不正确,因为搜索路径中没有“CUDA”; FWIW 我认为在 C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2
中搜索应该给出一个不同的错误,因为没有这样的文件夹(那里有一个旧的 V10.0 文件夹,但没有 OS 安装 CUDA 11)
Until/unless TensorFlow 改进了路径处理,每个新的 (Anaconda) python 环境都需要这样的文件结构操作。
TensorFlow 论坛中的完整线程here
对于 linux 用户,使用 tensorflow==2.8
添加以下环境变量。
XLA_FLAGS=--xla_gpu_cuda_data_dir=/usr/local/cuda-11.4
以下对我有用。错误信息:
error: Can't find libdevice directory ${CUDA_DIR}/nvvm/libdevice
首先我搜索了 nvvm
目录,然后验证了 libdevice
目录是否存在:
$ find / -type d -name nvvm 2>/dev/null
/usr/lib/cuda/nvvm
$ cd /usr/lib/cuda/nvvm
/usr/lib/cuda/nvvm$ ls
libdevice
/usr/lib/cuda/nvvm$ cd libdevice
/usr/lib/cuda/nvvm/libdevice$ ls
libdevice.10.bc
然后我导出了环境变量:
export XLA_FLAGS=--xla_gpu_cuda_data_dir=/usr/lib/cuda
如上图@Insectorious 所示。这解决了错误,我能够 运行 代码。
对于 Windows 用户
第一步
运行(作为管理员)
conda install -c anaconda cudatoolkit
您可以根据您安装的 cudaCNN /支持的版本指定 cudatoolkit 版本
ex:conda安装-c anaconda cudatoolkit=10.2.89
第 2 步
进入安装好的conada文件夹
C:\ProgramData\Anaconda3\Library\bin
第三步
找到“libdevice.10.bc”,复制文件
第四步
在 bin
中创建一个名为“nvvm”的文件夹
在 nvvm
中创建另一个名为“libdevice”的文件夹
将“libdevice.10.bc”文件粘贴到“libdevice”
第五步
转到环境变量
系统变量>新建
变量名:
XLA_FLAGS
变量值:
--xla_gpu_cuda_data_dir=C:\ProgramData\Anaconda3\Library\bin
(根据您的目录编辑以上内容)
第 6 步
重新启动 cmd/virtual env
Win 10 64位21H1; TF2.5, CUDA 11 安装环境 (Python 3.9.5 Xeus)
我不是唯一看到此错误的人;另见(未答复)here and here。 问题不明确,建议的解决方案 unclear/don 似乎不起作用(参见 here)
问题使用TFLinear_Mixed_Effects_Models.ipynb示例(从TensorFlow下载githubhere)执行达到执行“预热”的程度阶段”然后抛出错误:
InternalError: libdevice not found at ./libdevice.10.bc [Op:__inference_one_e_step_2806]
控制台包含此输出,表明它找到了 GPU,但 XLA 初始化未能找到 - 现有! - 指定路径中的 libdevice
2021-08-01 22:04:36.691300: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1418] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 9623 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
2021-08-01 22:04:37.080007: W tensorflow/python/util/util.cc:348] Sets are not currently considered sequences, but this may change in the future, so consider avoiding using them.
2021-08-01 22:04:54.122528: I tensorflow/compiler/xla/service/service.cc:169] XLA service 0x1d724940130 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2021-08-01 22:04:54.127766: I tensorflow/compiler/xla/service/service.cc:177] StreamExecutor device (0): NVIDIA GeForce GTX 1080 Ti, Compute Capability 6.1
2021-08-01 22:04:54.215072: W tensorflow/compiler/tf2xla/kernels/random_ops.cc:241] Warning: Using tf.random.uniform with XLA compilation will ignore seeds; consider using tf.random.stateless_uniform instead if reproducible behavior is desired.
2021-08-01 22:04:55.506464: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:73] Can't find libdevice directory ${CUDA_DIR}/nvvm/libdevice. This may result in compilation or runtime failures, if the program we try to run uses routines from libdevice.
2021-08-01 22:04:55.512876: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:74] Searched for CUDA in the following directories:
2021-08-01 22:04:55.517387: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] C:/Users/Julian/anaconda3/envs/TF250_PY395_xeus/Library/bin
2021-08-01 22:04:55.520773: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2
2021-08-01 22:04:55.524125: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] .
2021-08-01 22:04:55.526349: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:79] You can choose the search directory by setting xla_gpu_cuda_data_dir in HloModule's DebugOptions. For most apps, setting the environment variable XLA_FLAGS=--xla_gpu_cuda_data_dir=/path/to/cuda will work.
现在有趣的是,搜索到的路径包括“C:/Users/Julian/anaconda3/envs/TF250_PY395_xeus/Library/bin”
该文件夹的内容包括所有(在 TF 启动时成功加载的)DLL,包括 cudart64_110.dll、dudnn64_8.dll... 当然还有 libdevice.10.bc
问题既然 TF 说它正在搜索这个文件的这个位置并且文件存在于那里,那么问题是什么,我该如何解决?
(注意 C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2
不存在...环境中安装了 CUDA;此路径必须是 OS 安装的最佳猜测)
信息:我通过
设置路径aPath = '--xla_gpu_cuda_data_dir=C:/Users/Julian/anaconda3/envs/TF250_PY395_xeus/Library/bin'
print(aPath)
os.environ['XLA_FLAGS'] = aPath
但我还设置了一个 OS 环境变量 XLA_FLAGS 为相同的字符串值...我不知道哪个在实际工作,但控制台输出的事实说它搜索了预期的路径就足够了
诊断信息不明确,无帮助;但是有一个决议
通过在此路径提供文件(作为副本)解决了问题
C:\Users\Julian\anaconda3\envs\TF250_PY395_xeus\Library\bin\nvvm\libdevice\
请注意 C:\Users\Julian\anaconda3\envs\TF250_PY395_xeus\Library\bin
是给 XLA_FLAGS 的路径,但它似乎不是在寻找 libdevice file 而是在寻找\nvvm\libdevice\ path 这意味着我不能在 XLA_FLAGS 中设置一个不同的值来指向 libdevice 文件的实际位置,因为,短语,它不(只是)它正在寻找的文件。
之前的调试信息:
2021-08-05 08:38:52.889213: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:73] Can't find libdevice directory ${CUDA_DIR}/nvvm/libdevice. This may result in compilation or runtime failures, if the program we try to run uses routines from libdevice.
2021-08-05 08:38:52.896033: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:74] Searched for CUDA in the following directories:
2021-08-05 08:38:52.899128: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] C:/Users/Julian/anaconda3/envs/TF250_PY395_xeus/Library/bin
2021-08-05 08:38:52.902510: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2
2021-08-05 08:38:52.905815: W tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:77] .
不正确,因为搜索路径中没有“CUDA”; FWIW 我认为在 C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2
中搜索应该给出一个不同的错误,因为没有这样的文件夹(那里有一个旧的 V10.0 文件夹,但没有 OS 安装 CUDA 11)
Until/unless TensorFlow 改进了路径处理,每个新的 (Anaconda) python 环境都需要这样的文件结构操作。
TensorFlow 论坛中的完整线程here
对于 linux 用户,使用 tensorflow==2.8
添加以下环境变量。
XLA_FLAGS=--xla_gpu_cuda_data_dir=/usr/local/cuda-11.4
以下对我有用。错误信息:
error: Can't find libdevice directory ${CUDA_DIR}/nvvm/libdevice
首先我搜索了 nvvm
目录,然后验证了 libdevice
目录是否存在:
$ find / -type d -name nvvm 2>/dev/null
/usr/lib/cuda/nvvm
$ cd /usr/lib/cuda/nvvm
/usr/lib/cuda/nvvm$ ls
libdevice
/usr/lib/cuda/nvvm$ cd libdevice
/usr/lib/cuda/nvvm/libdevice$ ls
libdevice.10.bc
然后我导出了环境变量:
export XLA_FLAGS=--xla_gpu_cuda_data_dir=/usr/lib/cuda
如上图@Insectorious 所示。这解决了错误,我能够 运行 代码。
对于 Windows 用户
第一步
运行(作为管理员)
conda install -c anaconda cudatoolkit
您可以根据您安装的 cudaCNN /支持的版本指定 cudatoolkit 版本 ex:conda安装-c anaconda cudatoolkit=10.2.89
第 2 步
进入安装好的conada文件夹
C:\ProgramData\Anaconda3\Library\bin
第三步
找到“libdevice.10.bc”,复制文件
第四步
在 bin
中创建一个名为“nvvm”的文件夹在 nvvm
中创建另一个名为“libdevice”的文件夹将“libdevice.10.bc”文件粘贴到“libdevice”
第五步
转到环境变量
系统变量>新建
变量名:
XLA_FLAGS
变量值:
--xla_gpu_cuda_data_dir=C:\ProgramData\Anaconda3\Library\bin
(根据您的目录编辑以上内容)
第 6 步 重新启动 cmd/virtual env