Hanlp基于Tensorflow2.3.0解决:运行时总出现错误信息提示

Posted ZSYL

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hanlp基于Tensorflow2.3.0解决:运行时总出现错误信息提示相关的知识,希望对你有一定的参考价值。

Hanlp基于Tensorflow2.3.0解决:运行时总出现错误信息提示

问题描述

安装hanlp:

pip install hanlp[full]

分词代码运行时,总是有报错提示信息,可能是TensorflowGPU版本与显卡CUDA的版本不一致导致的。

2021-07-30 14:51:39.905911: 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-07-30 14:51:39.906120: 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.
2021-07-30 14:51:45.927620: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library nvcuda.dll
2021-07-30 14:51:46.617288: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce MX250 computeCapability: 6.1
coreClock: 1.582GHz coreCount: 3 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 44.76GiB/s
2021-07-30 14:51:46.620279: 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-07-30 14:51:46.620519: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cublas64_10.dll
2021-07-30 14:51:46.620747: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cufft64_10.dll
2021-07-30 14:51:46.621068: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library curand64_10.dll
2021-07-30 14:51:46.621277: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusolver64_10.dll
2021-07-30 14:51:46.621498: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusparse64_10.dll
2021-07-30 14:51:46.621802: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudnn64_7.dll
2021-07-30 14:51:46.622508: 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-07-30 14:51:48.724614: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-07-30 14:51:48.737260: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x2a89cd90ba0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-07-30 14:51:48.737667: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2021-07-30 14:51:48.737937: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-07-30 14:51:48.738081: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]  

解决办法

方式一:

如果是初学者 或者 没有太大计算速度的需求,在开头加上这两行忽略这个提示即可。

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

PS:

os.environ["TF_CPP_MIN_LOG_LEVEL"] = '1' # 默认,显示所有信息 
os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2' # 只显示 warning 和 Error 
os.environ["TF_CPP_MIN_LOG_LEVEL"] = '3' # 只显示 Error

方式二:

安装与显卡的CUDA版本相对应的Tensorflow版本。

具体内容,请参考:

win11-Tensorflow2.0(GPU)最新版安装

Could not load dynamic library ‘cudart64_110.dll‘; dlerror: cudart64_110.dll not found Ignore above

Link

以上是关于Hanlp基于Tensorflow2.3.0解决:运行时总出现错误信息提示的主要内容,如果未能解决你的问题,请参考以下文章

HanLP 基于朴素贝叶斯 训练 文本分类

日常查看Python库的本地安装信息及pip库的使用方法(补tensorflow2.3.0所有依赖whl)

HanLP 基于SVM支持向量机 训练 文本分类

HanLP 基于SVM支持向量机 训练 文本分类

数据挖掘:基于Spark+HanLP实现影视评论关键词抽取

HanLP 基于SVM支持向量机 进行 ChnSentiCorp 情感分析