bert-utils icon indicating copy to clipboard operation
bert-utils copied to clipboard

显存不足问题

Open jamesguo opened this issue 5 years ago • 1 comments

1080Ti 单卡 执行下面的代码,直接显存不足了,其他桌面程序用了400M

from extract_feature import BertVector
bv = BertVector()
print(bv.encode(['今天天气不错']))
2019-06-11 19:40:21.473032: I tensorflow/stream_executor/dso_loader.cc:152] successfully opened CUDA library libcublas.so.10.0 locally
2019-06-11 19:40:24.593479: E tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:216] failed to load CUBIN: Internal: failed to load in-memory CUBIN: CUDA_ERROR_OUT_OF_MEMORY: out of memory
2019-06-11 19:40:24.593505: F tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:881] Check failed: module != nullptr 

extract_feature.py 也改了配置

config.gpu_options.allow_growth = False
config.gpu_options.per_process_gpu_memory_fraction = 0.6

jamesguo avatar Jun 11 '19 11:06 jamesguo

@jamesguo 你改错了。下边时GPU使用率,你改成1.0,另外主要内存溢出是因为batch_size太大了,你设成32试试,或者将768的句向量映射为200维都可以减少训练显存消耗

Zhangpeixiang avatar Jun 26 '19 08:06 Zhangpeixiang