scalene: Cannot run scalene due to python2 dependency pynvml
Describe the bug When running scalene, it breaks with the error:
Traceback (most recent call last):
File "/usr/local/bin/scalene", line 5, in <module>
from scalene.__main__ import main
File "/usr/local/lib/python3.8/site-packages/scalene/__main__.py", line 4, in <module>
from scalene import scalene_profiler
File "/usr/local/lib/python3.8/site-packages/scalene/scalene_profiler.py", line 65, in <module>
from scalene.scalene_gpu import ScaleneGPU
File "/usr/local/lib/python3.8/site-packages/scalene/scalene_gpu.py", line 3, in <module>
import pynvml
File "/usr/local/lib/python3.8/site-packages/pynvml.py", line 1831
print c_count.value
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(c_count.value)?
If I looked through the issues correctly, I have seen that a similar problem happened in the past with the dependency nvidia-ml-py. However that past fix doesn’t seem to have worked here, when checking the install logs its installing nvidia-ml-py (375.53)
To Reproduce Steps to reproduce the behavior:
- Install scalene
- Run it from the CLI command
scalene program.py - See error
Expected behavior Scalene should profile the application normally.
Desktop (please complete the following information):
- OS: MacOS
- Version 11.6.3
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16 (7 by maintainers)
Commits related to this issue
- Added explicit pynvml requirement, fixing https://github.com/plasma-umass/scalene/issues/358. — committed to plasma-umass/scalene by emeryberger 2 years ago
- Slightly weakened pynvml requirement, hopefully actually fixing https://github.com/plasma-umass/scalene/issues/358. — committed to plasma-umass/scalene by emeryberger 2 years ago
This should be fixed in the current repo - please verify!
python3 -m pip install git+https://github.com/plasma-umass/scaleneI’m running into the same problem. I uninstalled scalene and nvidia-ml-py and tried installing from git as you instructed above. Same result.
Investigating further, the problem is the broken nvidia-ml-py package. It is published for python3, but it contains a built-in pynvml module that is written for python2. So if you don’t install a pynvml package explicitly, this broken version of the module is used.
Next, I explicitly installed the pynvml package, which provided the python3 version. This fixed it.
So I think you should: A) Add an explicit dependency on pynvml (perhaps with a version qualifier) B) Complain to the nvidia-ml-py maintainer that their package is broken. Oh wait, that’s maintained by NVidia. HAH. Good luck with that!
Hey, @emeryberger thanks for the fast response and for this cool project. First I tried running
python3 -m pip install -U git+https://github.com/plasma-umass/scalenein an isolatedvenvand the package version was the correct one.Then I attempted to do the same on my
poetryproject withpoetry add git+https://github.com/plasma-umass/scaleneand the version was also corrected.However it might be relevant to note that at my first attempt on doing it in my poetry project, it failed as my project had a minimum requirement for
python = ">=3.7.1,<3.10"which wasn’t compatible withscalene’s minimum version of 3.8. Which means that initially, for some reason just runningpoetry add scalenedidn’t pick up on this python version dependency as well.And even if now it does work, im facing the problem where scalene breaks with the error :
Scalene error: received signal SIGABRT. I have seen there was already an issue for it but it was closed, should I open up a new one?