bloomberg / memray

Memray is a memory profiler for Python
https://bloomberg.github.io/memray/
Apache License 2.0
13.17k stars 392 forks source link

The process completes without the file output progress bar reaching 100%. #486

Closed pea-sys closed 10 months ago

pea-sys commented 11 months ago

Is there an existing issue for this?

Current Behavior

When outputting a flame graph with Google Colab, the process completes without the progress bar displayed reaching 100%.

Expected Behavior

When the process is complete, the progress bar will be 100%

Steps To Reproduce

Collecting memray Downloading memray-1.10.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.4 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.4/3.4 MB 31.1 MB/s eta 0:00:00 Requirement already satisfied: jinja2>=2.9 in /usr/local/lib/python3.10/dist-packages (from memray) (3.1.2) Requirement already satisfied: rich>=11.2.0 in /usr/local/lib/python3.10/dist-packages (from memray) (13.6.0) Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2>=2.9->memray) (2.1.3) Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=11.2.0->memray) (3.0.0) Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=11.2.0->memray) (2.16.1) Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=11.2.0->memray) (0.1.2) Installing collected packages: memray Successfully installed memray-1.10.0

!memray run "/content/sample.py"

Writing profile results into /content/memray-sample.py.6740.bin Memray WARNING: Correcting symbol for aligned_alloc from 0x7b0c80e55d50 to 0x7b0c8190ac60 2023-10-28 22:29:58.166271: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered 2023-10-28 22:29:58.166355: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered 2023-10-28 22:29:58.166424: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered 2023-10-28 22:29:58.352861: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2023-10-28 22:30:06.797748: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT b'Hello, TensorFlow!' [memray] Successfully generated profile results.

You can now generate reports from the stored allocation records. Some example commands to generate reports:

/usr/bin/python3 -m memray flamegraph /content/memray-sample.py.6740.bin

!memray flamegraph "/content/memray-sample.py.6740.bin"


![sample](https://github.com/bloomberg/memray/assets/49807271/800b22e7-b5fc-410e-8223-533e9a8cd11d)

### Memray Version

1.10.0

### Python Version

3.10

### Operating System

Linux

### Anything else?

_No response_
pablogsal commented 10 months ago

Hi @pea-sys, can you provide the contents of "content/sample.py"?

pea-sys commented 10 months ago

@pablogsal

import tensorflow as tf
from tensorflow.keras.backend import eval

hello = tf.constant('Hello, TensorFlow!')
print(eval(hello))
pablogsal commented 10 months ago

~This in indeed odd, but it seems to be somehow related to how jupyter notebooks print terminal output when using the ! command. The same file locally prints without problem the full progress bar~

Ah, in the terminal the progress bar disappears quickly so is not easy to see whether they reach or not the end.