如何检查tensorflow是否使用了整个内存内存

时间:2019-07-10 16:47:10

标签: python ubuntu tensorflow keras

我感到有些奇怪。当我运行tensorflow program时,它会在运行之前打印出以下信息:

Colocations handled automatically by placer.
2019-07-10 10:36:53.985595: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2019-07-10 10:36:54.011139: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3192000000 Hz
2019-07-10 10:36:54.011914: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x562dbc64bb10 executing computations on platform Host. Devices:
2019-07-10 10:36:54.011928: I tensorflow/compiler/xla/service/service.cc:158]   StreamExecutor device (0): <undefined>, <undefined>
2019-07-10 10:36:54.113358: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-07-10 10:36:54.114017: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x562dbf2935a0 executing computations on platform CUDA. Devices:
2019-07-10 10:36:54.114028: I tensorflow/compiler/xla/service/service.cc:158]   StreamExecutor device (0): GeForce GTX 1080 Ti, Compute Capability 6.1
2019-07-10 10:36:54.114235: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties: 
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:01:00.0
totalMemory: 10.91GiB freeMemory: 10.19GiB
2019-07-10 10:36:54.114245: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
2019-07-10 10:36:54.115348: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-07-10 10:36:54.115355: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0 
2019-07-10 10:36:54.115359: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N 
2019-07-10 10:36:54.115505: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 9911 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
WARNING:tensorflow:From /home/sgnbx/anaconda3/envs/py3t2/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.

您看到它说:

totalMemory: 10.91GiB freeMemory: 10.19GiB

但是,当我使用以下命令检查命令中有多少内存时:

 free -g

我看到以下输出:

              total        used        free      shared  buff/cache   available
Mem:             31           5          24           0           1          25
Swap:             0           0           0

为什么tensorflow无法访问整个内存? 我可能错过了一些东西,请告诉我。

1 个答案:

答案 0 :(得分:1)

tensorflow/core/common_runtime/gpu/gpu_device.cc:1433行的tensorflow日志正在GPU上打印信息(设备0-还记下了源文件名gpu_device.cc):

2019-07-10 10:36:54.114235: I 
tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with 
properties: 
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:01:00.0
totalMemory: 10.91GiB freeMemory: 10.19GiB

GeForce GTX 1080 Ti的内存为11GB。

free命令显示系统(而不是显示卡)中的可用和已用内存量。