我要执行char-level text classification example,在使用--test_with_fake_data
运行时,一切正常:
$ python text_classification_character_cnn.py --test_with_fake_data
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally
WARNING:tensorflow:Using temporary folder as model directory: /tmp/tmpJCDcsa
WARNING:tensorflow:Setting feature info to TensorSignature(dtype=tf.float32, shape=TensorShape([Dimension(None), Dimension(100)]), is_sparse=False)
WARNING:tensorflow:Setting targets info to TensorSignature(dtype=tf.int32, shape=TensorShape([Dimension(None)]), is_sparse=False)
I tensorflow/core/common_runtime/gpu/gpu_init.cc:102] Found device 0 with properties:
name: GeForce GTX TITAN X
major: 5 minor: 2 memoryClockRate (GHz) 1.076
pciBusID 0000:02:00.0
Total memory: 12.00GiB
Free memory: 11.87GiB
I tensorflow/core/common_runtime/gpu/gpu_init.cc:126] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_init.cc:136] 0: Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:839] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX TITAN X, pci bus id: 0000:02:00.0)
I tensorflow/core/common_runtime/gpu/gpu_device.cc:839] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX TITAN X, pci bus id: 0000:02:00.0)
Accuracy: 1.000000
这意味着代码和环境是健康的。使用DBpedia数据集执行:
$ python text_classification_character_cnn.py
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally
WARNING:tensorflow:Using temporary folder as model directory: /tmp/tmpcMgfxe
WARNING:tensorflow:Setting feature info to TensorSignature(dtype=tf.float32, shape=TensorShape([Dimension(None), Dimension(100)]), is_sparse=False)
WARNING:tensorflow:Setting targets info to TensorSignature(dtype=tf.int32, shape=TensorShape([Dimension(None)]), is_sparse=False)
I tensorflow/core/common_runtime/gpu/gpu_init.cc:102] Found device 0 with properties:
name: GeForce GTX TITAN X
major: 5 minor: 2 memoryClockRate (GHz) 1.076
pciBusID 0000:02:00.0
Total memory: 12.00GiB
Free memory: 11.87GiB
I tensorflow/core/common_runtime/gpu/gpu_init.cc:126] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_init.cc:136] 0: Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:839] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX TITAN X, pci bus id: 0000:02:00.0)
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (256): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (512): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (1024): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (2048): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (4096): Total Chunks: 1, Chunks in use: 0 7.0KiB allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (8192): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (16384): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (32768): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (65536): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (131072): Total Chunks: 1, Chunks in use: 0 200.0KiB allocated for chunks. 200.0KiB client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (262144): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (524288): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (1048576): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (2097152): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (4194304): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (8388608): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (16777216): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (33554432): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (67108864): Total Chunks: 0, Chunks in use: 0 0B allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (134217728): Total Chunks: 1, Chunks in use: 0 213.62MiB allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:639] Bin (268435456): Total Chunks: 1, Chunks in use: 0 10.62GiB allocated for chunks. 0B client-requested for chunks. 0B in use in bin. 0B client-requested in use in bin.
I tensorflow/core/common_runtime/bfc_allocator.cc:656] Bin for 53.41GiB was 256.00MiB, Chunk State:
I tensorflow/core/common_runtime/bfc_allocator.cc:662] Size: 10.62GiB | Requested Size: 0B | in_use: 0, prev: Size: 427.25MiB | Requested Size: 427.25MiB | in_use: 1
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06d80000 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06d80100 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06d80200 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06d80300 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06d80400 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06d80500 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06d80600 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06d80700 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06d80800 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06d80900 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06d80a00 of size 204800
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06db2a00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06db2b00 of size 8192
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06db4b00 of size 768
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06db4e00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06db4f00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06db5000 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06db5100 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06db5200 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de7300 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de7400 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de7500 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de7600 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de7700 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de9400 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de9500 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de9600 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de9700 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de9800 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de9900 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de9a00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de9b00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06de9c00 of size 204800
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e1bc00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e1bd00 of size 204800
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e4dd00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e4de00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e4df00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e4e000 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e4e100 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e4e200 of size 204800
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e80200 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e80300 of size 8192
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e82300 of size 8192
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e84300 of size 768
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e84600 of size 768
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e84900 of size 8192
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e86900 of size 768
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e86c00 of size 256
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb06e86d00 of size 33600000
I tensorflow/core/common_runtime/bfc_allocator.cc:674] Chunk at 0xb16431700 of size 448000000
I tensorflow/core/common_runtime/bfc_allocator.cc:683] Free at 0xb06db5300 of size 204800
I tensorflow/core/common_runtime/bfc_allocator.cc:683] Free at 0xb06de7800 of size 7168
I tensorflow/core/common_runtime/bfc_allocator.cc:683] Free at 0xb08e91f00 of size 224000000
I tensorflow/core/common_runtime/bfc_allocator.cc:683] Free at 0xb30f70700 of size 11399076352
I tensorflow/core/common_runtime/bfc_allocator.cc:689] Summary of in-use Chunks by size:
I tensorflow/core/common_runtime/bfc_allocator.cc:692] 37 Chunks of size 256 totalling 9.2KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:692] 4 Chunks of size 768 totalling 3.0KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:692] 4 Chunks of size 8192 totalling 32.0KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:692] 4 Chunks of size 204800 totalling 800.0KiB
I tensorflow/core/common_runtime/bfc_allocator.cc:692] 1 Chunks of size 33600000 totalling 32.04MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:692] 1 Chunks of size 448000000 totalling 427.25MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] Sum Total of in-use chunks: 460.11MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:698] Stats:
Limit: 12105752781
InUse: 482464512
MaxInUse: 706464512
NumAllocs: 67
MaxAllocSize: 448000000
W tensorflow/core/common_runtime/bfc_allocator.cc:271] Ran out of memory trying to allocate 53.41GiB. See logs for memory state.
似乎TensorFlow需要53.41GiB
内存,这在Titan X中是不可用的。如果有人在运行这个例子中有实验,请帮助我。
答案 0 :(得分:3)
分类示例中的第102行
classifier.fit(x_train, y_train, steps=100)
fit()方法采用可选的batch_size参数。 它默认为x_train中的样本数。
尝试设置batch_size = 16并查看它需要多少内存。 如果有帮助,只要增加批量大小就增加批量 训练速度适合你的GPU。