bert icon indicating copy to clipboard operation
bert copied to clipboard

Error recorded from training_loop: Found Inf or NaN global norm. : Tensor had NaN values

Open zjwzcn07 opened this issue 7 years ago • 3 comments

I try to run run_classifier.sh in cpu, it runs ok. But when I run in gpu, sometimes good, sometimes bad. I think it might have something to do with seq_max_length and batch_size. But it's useless to reduce seq_max_length and batch_size. (I've tried it.)

following is my run_classifier.sh

python3.5 run_classifier.py
--task_name=sim
--do_train=true
--do_eval=true
--do_predict=true
--data_dir=$MY_DATASET
--vocab_file=$BERT_BASE_DIR/vocab.txt
--bert_config_file=$BERT_BASE_DIR/bert_config.json
--init_checkpoint=$BERT_BASE_DIR/bert_model.ckpt
--max_seq_length=128
--train_batch_size=32
--learning_rate=2e-5
--num_train_epochs=2.0 \

following is error log

2019-03-21 14:21:12.342706: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0, 1, 2, 3 2019-03-21 14:21:13.673814: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix: 2019-03-21 14:21:13.673891: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988] 0 1 2 3 2019-03-21 14:21:13.673904: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0: N N N N 2019-03-21 14:21:13.673912: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 1: N N N N 2019-03-21 14:21:13.673918: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 2: N N N N 2019-03-21 14:21:13.673925: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 3: N N N N 2019-03-21 14:21:13.675250: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 15119 MB memory) -> physical GPU (device: 0, name: Tesla P100-PCIE-16GB, pc i bus id: 0000:00:07.0, compute capability: 6.0) 2019-03-21 14:21:13.676003: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 15119 MB memory) -> physical GPU (device: 1, name: Tesla P100-PCIE-16GB, pc i bus id: 0000:00:08.0, compute capability: 6.0) 2019-03-21 14:21:13.676420: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:2 with 15119 MB memory) -> physical GPU (device: 2, name: Tesla P100-PCIE-16GB, pc i bus id: 0000:00:09.0, compute capability: 6.0) 2019-03-21 14:21:13.676764: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:3 with 15119 MB memory) -> physical GPU (device: 3, name: Tesla P100-PCIE-16GB, pc i bus id: 0000:00:0a.0, compute capability: 6.0) INFO:tensorflow:Running local_init_op. INFO:tensorflow:Done running local_init_op. INFO:tensorflow:Saving checkpoints for 0 into ./mayi_model_2/model.ckpt. 2019-03-21 14:22:44.995671: E tensorflow/core/kernels/check_numerics_op.cc:185] abnormal_detected_host @0x1085900ab00 = {1, 0} Found Inf or NaN global norm. INFO:tensorflow:Error recorded from training_loop: Found Inf or NaN global norm. : Tensor had NaN values [[node VerifyFinite/CheckNumerics (defined at /var/log//bert_chi/optimization.py:74) = CheckNumerics[T=DT_FLOAT, message="Found Inf or NaN global norm.", _device="/job:localhost/replica:0/task:0/device:GPU:0"](global_n orm/global_norm)]]

zjwzcn07 avatar Mar 21 '19 08:03 zjwzcn07

@zjwzcn07 : Have you solved this issue ? I also get these errors in serveral days.

ntson2002 avatar May 07 '19 02:05 ntson2002

@ntson2002 you can try this nvidia-smi -pm 1

zjwzcn07 avatar May 12 '19 05:05 zjwzcn07

@zjwzcn07 thanks for the suggestion. I try but I still got these errorrs even though I run experiments on the dataset mentioned in the bert repo.

ntson2002 avatar May 16 '19 11:05 ntson2002