import hanlp 的时候报错。在此之前加载了一个模型,然后再import hanlp报以下的错误:请问如何解决
``
RuntimeError Traceback (most recent call last)
in
----> 1 import hanlp
2 # from hanlp.components.mtl.multi_task_learning import MultiTaskLearning
3 # from hanlp_common.document import Document
4 # from hanlp.utils import rules
5 # import pandas as pd
/opt/conda/lib/python3.8/site-packages/hanlp/init.py in
29 if not os.environ.get(‘HANLP_GREEDY_GPU’, None):
30 exec(‘from hanlp.utils.tf_util import nice_gpu’)
—> 31 exec(‘nice_gpu()’)
32
33 exec(’’’
/opt/conda/lib/python3.8/site-packages/hanlp/init.py in
/opt/conda/lib/python3.8/site-packages/hanlp/utils/tf_util.py in nice_gpu()
82 Use GPU nicely.
83 “”"
—> 84 set_gpu_memory_growth()
85 set_gpu()
86
/opt/conda/lib/python3.8/site-packages/hanlp/utils/tf_util.py in set_gpu_memory_growth(growth)
75 # Memory growth must be set before GPUs have been initialized
76 # print(e)
—> 77 raise e
78
79
/opt/conda/lib/python3.8/site-packages/hanlp/utils/tf_util.py in set_gpu_memory_growth(growth)
71 # Currently, memory growth needs to be the same across GPUs
72 for gpu in gpus:
—> 73 tf.config.experimental.set_memory_growth(gpu, growth)
74 except RuntimeError as e:
75 # Memory growth must be set before GPUs have been initialized
/opt/conda/lib/python3.8/site-packages/tensorflow/python/framework/config.py in set_memory_growth(device, enable)
498 RuntimeError: Runtime is already initialized.
499 “”"
–> 500 context.context().set_memory_growth(device, enable)
501
502
/opt/conda/lib/python3.8/site-packages/tensorflow/python/eager/context.py in set_memory_growth(self, dev, enable)
1323
1324 if self._context_handle is not None:
-> 1325 raise RuntimeError(
1326 “Physical devices cannot be modified after being initialized”)
1327
``