# GPU&CPU使用情況
### 觀察GPU使用量
每10秒print
>watch -n 10 nvidia-smi
Memory-Usage 內存使用量
GPU-Util GPU使用量
> https://blog.csdn.net/autoliuweijie/article/details/53170325
## Zero volatile GPU-Util but high GPU Memory Usage
參考以下解決方式
>1.https://michaelblogscode.wordpress.com/2017/10/10/reducing-and-profiling-gpu-memory-usage-in-keras-with-tensorflow-backend/
>2.https://blog.csdn.net/qq_35082030/article/details/78186503
```python
## extra imports to set GPU options
import tensorflow as tf
from keras import backend as k
###################################
# TensorFlow wizardry
config = tf.ConfigProto()
# Don't pre-allocate memory; allocate as-needed
config.gpu_options.allow_growth = True
# Only allow a total of half the GPU memory to be allocated
config.gpu_options.per_process_gpu_memory_fraction = 0.5
# Create a session with the above options specified.
k.tensorflow_backend.set_session(tf.Session(config=config))
###################################
```
## 查看CPU
查看使用率
>top
> http://blog.xuite.net/zerofirst/blog/147985077-Linux%E6%9F%A5%E7%9C%8BCPU%E5%80%8B%E6%95%B8%2F%E5%A4%9A%E6%A0%B8%2F%E5%A4%9A%E5%9F%B7%E8%A1%8C%E7%B7%92%E7%9A%84%E6%9F%A5%E7%9C%8B
###### tags: `linux`