bert icon indicating copy to clipboard operation
bert copied to clipboard

run run_pretraining.py but use CPU instead of GPU

Open diqiuzhuanzhuan opened this issue 8 years ago • 3 comments

  1. when I use run_pretraining.py to pre-train my model, I have found it use all the memory of GPU, but use CPU to do a lot of computation. type the command "nvtop", the print like below:

Device 0 [GeForce GTX 1080 Ti] PCIe GEN 1@16x RX: 0.000 kB/s TX: 0.000 kB/s GPU 139MHz MEM 405MHz TEMP 44°C FAN 35% POW 18 / 250 W GPU-Util[ 0%] MEM-Util[||||||||||||11.2G/11.7G] Encoder[ 0%] Decoder[ 0%]

Device 1 [GeForce GTX 1080 Ti] PCIe GEN 1@ 4x RX: 0.000 kB/s TX: 0.000 kB/s GPU 139MHz MEM 405MHz TEMP 42°C FAN 34% POW 17 / 250 W GPU-Util[ 0%] MEM-Util[ 0.0G/11.7G] Encoder[ 0%] Decoder[ 0%]

PID USER GPU TYPE MEM Command 15353 feynman 0 Compute 11168Mo 95.3% python

we can see GPU-Util is 0%, and MEM-Util is nearly 100%

diqiuzhuanzhuan avatar Nov 02 '18 04:11 diqiuzhuanzhuan

We use a pretty standard interface to TensorFlow so I'm guessing it's either a TensorFlow config issue, a data issue, or a hyperparameter issue. If it's using all of your GPU memory my guess is that it is actually using your GPU.

Is it actually training? How many steps are you running? If you have it run for say, 200 steps with batch size 8, how long does it take to complete? If your data file is empty for some reason then it might just be hanging (this is a general Dataset API issue). If you are only running for 20 steps like the example then you might not be checking the utilization at the right time, and most of the time may be in graph building and checkpoint writing mode.

jacobdevlin-google avatar Nov 02 '18 04:11 jacobdevlin-google

Hi, thank you for your reply。I think I can sure it use CPU to train。As I can see the print info say ”INFO:tensorflow:Running train on CPU“ The total message is below: INFO:tensorflow:*** Input Files *** INFO:tensorflow: ./bert.txt WARNING:tensorflow:Estimator's model_fn (<function model_fn_builder..model_fn at 0x7f9354ee91e0>) includes params argument, but params are not passed to Estimator. INFO:tensorflow:Using config: {'_model_dir': 'checkpoint/bert/', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': 1000, '_save_checkpoints_secs': None, '_session_config': allow_soft_placement: true graph_options { rewrite_options { meta_optimizer_iterations: ONE } } , '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': None, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7f9328bbbc88>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1, '_tpu_config': TPUConfig(iterations_per_loop=1000, num_shards=8, num_cores_per_replica=None, per_host_input_for_training=3, tpu_job_name=None, .... .... .... INFO:tensorflow:Graph was finalized. 2018-11-02 11:57:51.516763: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2018-11-02 11:57:51.607535: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:964] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2018-11-02 11:57:51.608120: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 0 with properties: name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.6575 pciBusID: 0000:01:00.0 totalMemory: 10.91GiB freeMemory: 10.76GiB 2018-11-02 11:57:51.608140: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1490] Adding visible gpu devices: 0 2018-11-02 11:57:51.799679: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix: 2018-11-02 11:57:51.799714: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] 0 2018-11-02 11:57:51.799723: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0: N 2018-11-02 11:57:51.799904: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10405 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1) INFO:tensorflow:Running local_init_op. INFO:tensorflow:Done running local_init_op.

In the begin, we see a message of training on CPU, and in the end, we see GPU use information. I don't know what cause this problem。

diqiuzhuanzhuan avatar Nov 02 '18 05:11 diqiuzhuanzhuan

We use a pretty standard interface to TensorFlow so I'm guessing it's either a TensorFlow config issue, a data issue, or a hyperparameter issue. If it's using all of your GPU memory my guess is that it is actually using your GPU.

Is it actually training? How many steps are you running? If you have it run for say, 200 steps with batch size 8, how long does it take to complete? If your data file is empty for some reason then it might just be hanging (this is a general Dataset API issue). If you are only running for 20 steps like the example then you might not be checking the utilization at the right time, and most of the time may be in graph building and checkpoint writing mode.

Oh I am so sorry! You are right! My datafile is empty! Sorry for this stupid mistake! Please forgive me!

diqiuzhuanzhuan avatar Nov 02 '18 05:11 diqiuzhuanzhuan