scalene
scalene copied to clipboard
GPU, Memory Usage, and Copy Column Not Displaying in Scalene Profiling Output
Describe the bug I am trying to use Scalene to profile my Python code, but I've encountered an issue where the GPU, memory usage, and copy columns are not displaying correctly in the profiling output.
To Reproduce Steps to reproduce the behavior:
- Create module.
# my_profiling.py
import numpy as np
if __name__ == "__main__":
for _ in range(100):
arr = np.array(np.array(np.array(np.array(np.random.random((100_000, 10))))))
- Terminal: conda activate my_env
- Terminal: cd /path_to_my_file/
- Terminal: scalene --cli my_profiling.py
- See result
my_profiling.py: % of time = 100.00% (2.941s) out of 2.941s.
╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷
│Time │–––––– │––––… │–––––– │Memory │–––––– │––––––––––– │Copy │
Line │Python │native │syst… │GPU │Python │peak │timeline/% │(MB/s) │/home/dlxxx/Dokumente/python/profiling/my_profiling.py
╺━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
1 │ 1% │ 4% │ 1% │ 2% │ │ │ │ │import numpy as np
2 │ │ │ │ │ │ │ │ │
3 │ │ │ │ │ │ │ │ │if __name__ == "__main__":
4 │ │ │ │ │ │ │ │ │ for _ in range(100):
5 │ 48% │ 17% │ 28% │ 98% │ │ │ │ │ arr = np.array(np.array(np.array(np.array(np.random.random((100_000, 10))))))
6 │ │ │ │ │ │ │ │ │
╵ ╵ ╵ ╵ ╵ ╵ ╵ ╵ ╵
NOTE: The GPU is currently running in a mode that can reduce Scalene's accuracy when reporting GPU utilization.
Run once as Administrator or root (i.e., prefixed with `sudo`) to enable per-process GPU accounting.
- There is a note: "enable per-process GPU accounting."
- Get Python path for virtual environment: Terminal: which python3
- Terminal: sudo /home/xxx/miniconda3/envs/my_env/bin/python3 -m scalene --cli my_profiling.py
- See result
my_profiling.py: % of time = 100.00% (2.808s) out of 2.808s.
╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷
│Time │–––––– │––––… │–––––– │Memory │–––––– │––––––––––– │Copy │
Line │Python │native │syst… │GPU │Python │peak │timeline/% │(MB/s) │/home/dlxxx/Dokumente/python/profiling/my_profiling.py
╺━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
1 │ 2% │ 3% │ │ │ │ │ │ │import numpy as np
2 │ │ │ │ │ │ │ │ │
3 │ │ │ │ │ │ │ │ │if __name__ == "__main__":
4 │ │ │ │ │ │ │ │ │ for _ in range(100):
5 │ 52% │ 16% │ 26% │ │ │ │ │ │ arr = np.array(np.array(np.array(np.array(np.random.random((100_000, 10))))))
6 │ │ │ │ │ │ │ │ │
Expected behavior The output I get from Scalene does not show the GPU, memory usage, and copy columns as expected. Instead, these columns appear empty, and the values are not displayed.
Desktop (please complete the following information):
- OS: Linux Mint 21.2
- Browser Firefox version 119.0
- Python version 3.10.13
- Scalene version 1.5.31.1 (2023.09.15)
I have changed the versioning in my virtual environment:
- upgrade Python version from 3.10.13 => 3.11.5
- downgrade Scalene from version 1.5.31.1 (2023.09.15) => 1.5.19 (2023.01.06)
Then I have made another test. This time memory usage, and copy columns are displaying correctly in the profiling output. I am not sure what has solved the issue the Python upgrade, the Scalene downgrade or both.
scalene --cli test.py
Computing...
Finished!
29 0 0.967741935483871
37 0 0.9743589743589743
4 0 0.8333333333333334
0 0 0.5
Memory usage: ▁▁▁▁▂▂▂▂▂▂▃▃▃▃▄▄▅▅▆▆▆▆▇▇▇██ (max: 949.711 MB, growth rate: 74%)
test.py: % of time = 100.00% (5.670s) out of 5.670s.
╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷
│Time │–––––– │––––… │–––––– │Memory │–––––– │––––––––––– │Copy │
Line │Python │native │syst… │GPU │Python │peak │timeline/% │(MB/s) │test.py
╺━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
1 │ │ │ │ │ │ │ │ │#!/usr/bin/env python3
2 │ │ │ │ │ │ │ │ │# -*- coding: utf-8 -*-
3 │ │ │ │ │ │ │ │ │"""Test module for profiling."""
4 │ │ │ │ │ │ │ │ │
5 │ 4% │ 3% │ │ │ 100% │ 10M │▁ │ 19 │import numpy as np
6 │ │ │ │ │ │ │ │ │
7 │ │ │ │ │ │ │ │ │def compute():
8 │ │ │ │ │ │ │ │ │ size = 10_000_000
9 │ │ │ │ │ │ │ │ │ # High memory allocation
10 │ 21% │ 5% │ 7% │ │ 100% │ 394M │▁▁▁▁▁▁▂▂▂ 33% │ │ x = [i for i in range(size)]
11 │ 21% │ 4% │ 5% │ │ 100% │ 390M │▂▂▂▂▂▂▂▃▃ 33% │ │ y = [i for i in range(size)]
12 │ │ 2% │ 3% │ │ │ 156M │▃▃▃▃▃▃▃▃▃ 33% │ 59 │ z = np.array(np.array(np.array(np.array(np.arange(size)))))
13 │ │ │ │ │ │ │ │ │ # High computation time
14 │ │ │ │ │ │ │ │ │ for i in range(size):
15 │ 23% │ │ │ │ │ │ │ │ y[i] = y[i] * y[i]
16 │ │ │ │ │ │ │ │ │
17 │ │ │ │ │ │ │ │ │if __name__ == "__main__":
18 │ │ │ │ │ │ │ │ │ print('Computing...')
19 │ │ │ │ │ │ │ │ │ compute()
20 │ │ │ │ │ │ │ │ │ print('Finished!')
21 │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ │
╶──────┼───────┼───────┼──────┼───────┼───────┼───────┼───────────────┼───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╴
│ │ │ │ │ │ │ │ │function summary for test.py
7 │ 65% │ 14% │ 14% │ │ 67% │ 394M │█████████ 99% │ 59 │compute
╵ ╵ ╵ ╵ ╵ ╵ ╵ ╵ ╵
Top AVERAGE memory consumption, by line:
(1) 10: 394 MB
(2) 11: 390 MB
(3) 12: 156 MB
(4) 5: 10 MB
Top PEAK memory consumption, by line:
(1) 10: 394 MB
(2) 11: 390 MB
(3) 12: 156 MB
(4) 5: 10 MB
Possible memory leak identified at line 11 (estimated likelihood: 97%, velocity: 69 MB/s)
Possible memory leak identified at line 10 (estimated likelihood: 97%, velocity: 69 MB/s)
NOTE: The GPU is currently running in a mode that can reduce Scalene's accuracy when reporting GPU utilization.
Run once as Administrator or root (i.e., prefixed with `sudo`) to enable per-process GPU accounting.
scalene --version
Scalene version 1.5.19 (2023.01.06)
Had same issue. After some trial and error, found that the issue occurs between these two versions https://github.com/plasma-umass/scalene/compare/v1.5.22.2...v1.5.23
My setup: Python 3.10.12 OS: running in WSL Ubuntu 22.04.3 LTS
I have changed the versioning in my virtual environment:
- upgrade Python version from 3.10.13 => 3.11.5
- downgrade Scalene from version 1.5.31.1 (2023.09.15) => 1.5.19 (2023.01.06)
Then I have made another test. This time memory usage, and copy columns are displaying correctly in the profiling output. I am not sure what has solved the issue the Python upgrade, the Scalene downgrade or both.
scalene --cli test.py Computing... Finished! 29 0 0.967741935483871 37 0 0.9743589743589743 4 0 0.8333333333333334 0 0 0.5 Memory usage: ▁▁▁▁▂▂▂▂▂▂▃▃▃▃▄▄▅▅▆▆▆▆▇▇▇██ (max: 949.711 MB, growth rate: 74%) test.py: % of time = 100.00% (5.670s) out of 5.670s. ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ │Time │–––––– │––––… │–––––– │Memory │–––––– │––––––––––– │Copy │ Line │Python │native │syst… │GPU │Python │peak │timeline/% │(MB/s) │test.py ╺━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸ 1 │ │ │ │ │ │ │ │ │#!/usr/bin/env python3 2 │ │ │ │ │ │ │ │ │# -*- coding: utf-8 -*- 3 │ │ │ │ │ │ │ │ │"""Test module for profiling.""" 4 │ │ │ │ │ │ │ │ │ 5 │ 4% │ 3% │ │ │ 100% │ 10M │▁ │ 19 │import numpy as np 6 │ │ │ │ │ │ │ │ │ 7 │ │ │ │ │ │ │ │ │def compute(): 8 │ │ │ │ │ │ │ │ │ size = 10_000_000 9 │ │ │ │ │ │ │ │ │ # High memory allocation 10 │ 21% │ 5% │ 7% │ │ 100% │ 394M │▁▁▁▁▁▁▂▂▂ 33% │ │ x = [i for i in range(size)] 11 │ 21% │ 4% │ 5% │ │ 100% │ 390M │▂▂▂▂▂▂▂▃▃ 33% │ │ y = [i for i in range(size)] 12 │ │ 2% │ 3% │ │ │ 156M │▃▃▃▃▃▃▃▃▃ 33% │ 59 │ z = np.array(np.array(np.array(np.array(np.arange(size))))) 13 │ │ │ │ │ │ │ │ │ # High computation time 14 │ │ │ │ │ │ │ │ │ for i in range(size): 15 │ 23% │ │ │ │ │ │ │ │ y[i] = y[i] * y[i] 16 │ │ │ │ │ │ │ │ │ 17 │ │ │ │ │ │ │ │ │if __name__ == "__main__": 18 │ │ │ │ │ │ │ │ │ print('Computing...') 19 │ │ │ │ │ │ │ │ │ compute() 20 │ │ │ │ │ │ │ │ │ print('Finished!') 21 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╶──────┼───────┼───────┼──────┼───────┼───────┼───────┼───────────────┼───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╴ │ │ │ │ │ │ │ │ │function summary for test.py 7 │ 65% │ 14% │ 14% │ │ 67% │ 394M │█████████ 99% │ 59 │compute ╵ ╵ ╵ ╵ ╵ ╵ ╵ ╵ ╵ Top AVERAGE memory consumption, by line: (1) 10: 394 MB (2) 11: 390 MB (3) 12: 156 MB (4) 5: 10 MB Top PEAK memory consumption, by line: (1) 10: 394 MB (2) 11: 390 MB (3) 12: 156 MB (4) 5: 10 MB Possible memory leak identified at line 11 (estimated likelihood: 97%, velocity: 69 MB/s) Possible memory leak identified at line 10 (estimated likelihood: 97%, velocity: 69 MB/s) NOTE: The GPU is currently running in a mode that can reduce Scalene's accuracy when reporting GPU utilization. Run once as Administrator or root (i.e., prefixed with `sudo`) to enable per-process GPU accounting. scalene --version Scalene version 1.5.19 (2023.01.06)
Same here. Python 3.12, OS: OSX 14.1.2, M1
scalene 1.15.31.1 can not display memory info. Downgrade to python3.11.5, scalene 1.15.19, it worked.
already tried: python 3.11.5+scalene 1.15.22/26/30 and python3.12+scalene 1.15.31.1/26/30, there are no mem info for these combinations.
Hey team, I have faced with the same issue.
I wanted to get memory profiling results, but I haven't got anything in memory colomn.
Tried the latest version python.3.11 (3.11.9), python3.10 with v1.5.38 and 1.5.19 on Ubuntu 22.04 I have tried the scenario with python 3.11.5 and 1.5.19 (2023.01.06) on macos ventura arm.
No success :( The column in cli output or json "memory_samples" are empty :(