5

나는 tensorflow가있는 CNN 모델을 교육하고 있습니다. GPU 사용률을 크게 떨어 뜨리지 않고 60 % (± 2-3 %) 만 달성합니다.Tensorflow GPU 사용률이 60 % (GTX 1070)

Sun Oct 23 11:34:26 2016  
+-----------------------------------------------------------------------------+ 
| NVIDIA-SMI 367.57     Driver Version: 367.57     | 
|-------------------------------+----------------------+----------------------+ 
| GPU Name  Persistence-M| Bus-Id  Disp.A | Volatile Uncorr. ECC | 
| Fan Temp Perf Pwr:Usage/Cap|   Memory-Usage | GPU-Util Compute M. | 
|===============================+======================+======================| 
| 0 GeForce GTX 1070 Off | 0000:01:00.0  Off |     N/A | 
| 1% 53C P2 90W/170W | 7823MiB/8113MiB |  60%  Default | 
+-------------------------------+----------------------+----------------------+ 

+-----------------------------------------------------------------------------+ 
| Processes:              GPU Memory | 
| GPU  PID Type Process name        Usage  | 
|=============================================================================| 
| 0  3644 C /usr/bin/python2.7       7821MiB | 
+-----------------------------------------------------------------------------+ 

그것이 내가 5.1.5 cudnn CPU 사용과 CUDA 8을 사용하고 파스칼 카드 이래로 약 50 % (균등 8 개 스레드에 분산. I7의 4770k)이기 때문에, CPU 성능 병목 안 .

sess = tf.Session() 

sess.run(init) 
tf.train.start_queue_runners(sess=sess) 
for step in xrange(FLAGS.max_steps): 
    labels, images = sess.run([labels_batch, images_batch]) 
    feed_dict = {images_placeholder: images, labels_placeholder: labels} 
    _, loss_value = sess.run([train_op, loss], 
           feed_dict=feed_dict) 
: 여기
#Uses tf.TFRecordReader() to read single Example 
label, image = read_and_decode_single_example(filename_queue=filename_queue) 
image = tf.image.decode_jpeg(image.values[0], channels=3) 
jpeg = tf.cast(image, tf.float32)/255. 
jpeg.set_shape([66,200,3]) 
images_batch, labels_batch = tf.train.shuffle_batch(
    [jpeg, label], batch_size= FLAGS.batch_size, 
    num_threads=8, 
    capacity=2000, #tried bigger values here, does not change the performance 
    min_after_dequeue=1000) #here too 

내 교육 루프 :

내가 가진 Tensorflow의 바이너리 파일 형식을 사용하고이 같은 이미지의 배치를 만드는거야 tf.TFRecordReader()

읽을거야

나는 tensorflow에 대한 많은 경험이 없으며 병목 현상이 발생할 수있는 곳에서 지금은하지 않습니다. 문제를 식별하는 데 도움이되는 코드 스 니펫이 더 필요한 경우이를 제공 할 것입니다.

UPDATE : 대역폭 테스트

==5172== NVPROF is profiling process 5172, command: ./bandwidthtest 

Device: GeForce GTX 1070 
Transfer size (MB): 3960 

Pageable transfers 
    Host to Device bandwidth (GB/s): 7.066359 
    Device to Host bandwidth (GB/s): 6.850315 

Pinned transfers 
    Host to Device bandwidth (GB/s): 12.038037 
    Device to Host bandwidth (GB/s): 12.683915 

==5172== Profiling application: ./bandwidthtest 
==5172== Profiling result: 
Time(%)  Time  Calls  Avg  Min  Max Name 
50.03% 933.34ms   2 466.67ms 327.33ms 606.01ms [CUDA memcpy DtoH] 
49.97% 932.32ms   2 466.16ms 344.89ms 587.42ms [CUDA memcpy HtoD] 

==5172== API calls: 
Time(%)  Time  Calls  Avg  Min  Max Name 
46.60% 1.86597s   4 466.49ms 327.36ms 606.15ms cudaMemcpy 
35.43% 1.41863s   2 709.31ms 632.94ms 785.69ms cudaMallocHost 
17.89% 716.33ms   2 358.17ms 346.14ms 370.19ms cudaFreeHost 
    0.04% 1.5572ms   1 1.5572ms 1.5572ms 1.5572ms cudaMalloc 
    0.02% 708.41us   1 708.41us 708.41us 708.41us cudaFree 
    0.01% 203.58us   1 203.58us 203.58us 203.58us cudaGetDeviceProperties 
    0.00% 187.55us   1 187.55us 187.55us 187.55us cuDeviceTotalMem 
    0.00% 162.41us  91 1.7840us  105ns 61.874us cuDeviceGetAttribute 
    0.00% 79.979us   4 19.994us 1.9580us 73.537us cudaEventSynchronize 
    0.00% 77.074us   8 9.6340us 1.5860us 28.925us cudaEventRecord 
    0.00% 19.282us   1 19.282us 19.282us 19.282us cuDeviceGetName 
    0.00% 17.891us   4 4.4720us  629ns 8.6080us cudaEventDestroy 
    0.00% 16.348us   4 4.0870us  818ns 8.8600us cudaEventCreate 
    0.00% 7.3070us   4 1.8260us 1.7040us 2.0680us cudaEventElapsedTime 
    0.00% 1.6670us   3  555ns  128ns 1.2720us cuDeviceGetCount 
    0.00%  813ns   3  271ns  142ns  439ns cuDeviceGet 
+1

첫 - *일괄**? 그리고 당신의 모델은 얼마나 큰가요? 문제가 CPU와 GPU간에 동기화되고 있는지 확인하기 위해 더 큰 CNN을 구축하고 (더 많은 데이터를 단일 배치로 밀어 넣으십시오) 시도해 주시겠습니까? – lejlot

+0

@lejlot 그는 이미 GPU 메모리를 극대화하고 있습니다. –

+1

@FranckDernoncourt Tensorflow는 구성하지 않으면 가능한 한 많은 GPU 메모리를 항상 차지합니다. –

답변

1

tensorflow에 대한 경험을 더 얻은 후 GPU 사용은 네트워크 크기, 배치 크기 및 전처리에 크게 의존한다는 것을 알았습니다. 더 많은 계산이 포함되어 있고 계산과 관련하여 더 적은 오버 헤드가 데이터를 전송하여 생성되기 때문에 더 많은 전환 레이어 (예 : Resnet 스타일)가있는 더 큰 네트워크를 사용하면 GPU 사용이 증가합니다.

0

하나의 잠재적 인 병목 현상은 CPU와 GPU는 GPU에 이미지를로드 사이의 PCI Express 버스를 사용하다 발생합니다. tools to measure it을 사용할 수 있습니다.

또 다른 잠재적 인 병목 현상은 디스크 IO입니다. 코드에서 문제를 일으킬만한 것이 보이지 않지만 항상주의해야합니다.

+0

디스크 IO 병목 상태를 확인하는 가장 좋은 방법은 무엇입니까? SSD를 사용 중이며 데이터가 바이너리 파일입니다. 문제가 있다면 병목 현상을 개선 할 수있는 방법이 없습니다./ –

+0

@andre_bauer Linux에서'iotop '을 사용합니다. –

+0

나는 트레이닝 데이터 1.7GB (현재는)를 가지고 있으며 디스크가 완전히 유휴 상태라고합니다. 왜냐하면 everythink는 RAM에 있다고 생각하기 때문입니다. (더 많은 트레이닝 데이터를위한 공간이 있습니다!) –

관련 문제