找不到 TensorFlow libdevice。为什么在搜索路径中找不到它?

时间:2021-08-01 21:37:27

标签: python tensorflow configuration

Win 10 64 位 21H1; TF2.5, CUDA 11 环境安装(Python 3.9.5 Xeus)

我不是唯一一个看到这个错误的人;另见(未回答)herehere。 问题不明确,提议的解决方案不明确/似乎不起作用(参见例如 here

问题 使用 TF Linear_Mixed_Effects_Models.ipynb 示例(从 TensorFlow github here 下载)执行达到执行“预热阶段”的点然后抛出错误:

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;此路径必须是操作系统安装的最佳猜测)

信息:我正在设置路径

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 设置为相同的字符串值......我不知道哪个实际上在工作,但控制台输出表明它搜索了预期路径这一事实已经足够了< /p>

1 个答案:

答案 0 :(得分:0)

诊断信息有用且不清楚;但是有一个解决方案

问题已通过在此路径提供文件(作为副本)解决

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 文件夹,但没有安装 CUDA 11 的操作系统)

除非/除非 TensorFlow 改进了路径处理,否则在每个新的 (Anaconda) python 环境中都需要此类文件结构操作。

TensorFlow 论坛中的完整主题 here