Profiling Python with Nvidia NSight - python

Does anyone know how to profile Python scripts with NVIDIA Nsight Systems?
I'm not sure what I would put in the Target Application field. I tried putting in the Spyder IDE (from Anaconda) and then executing my Python script from there, but I can't seem to import Tensorflow when I do that.
As soon as I import Tensorflow and use it, it tells me "no such module". It seems that the Spyder IDE that I open from NSight Systems is different from the one when I open it normally (without Nsight).

I solved this in windows using the answer from nvidia forum:
So basically you should use a proper python environment and use the complete python directory like:
nsys profile C:\Users\beru\AppData\Local\Programs\Python\Python38\python.exe demo.py
By the way, this answer also helps me to know what to do for profiling python code using nsight system on win. I strongly recommend anyone puzzled by this read it.

Related

Is there a way to download Python for Visual Studio on MacOS?

Needless to say I'm not very good at setting up IDEs yet. I have about four different projects I'm working on right now and I decided I'd like to have some mobility by being able to take my MacBook around and still code with it away from my PC.
Setting up Visual Studio on my PC was really simple. It had a checklist of extensions/developer languages to choose from at install and Python was right there. Fast forward to installing it on my MacBook and it pretty much has C#, F#, and that's it.
Am I missing something obvious like Python doesn't work on MacOS?
It 100% should be available. You should be able to install it directly from the Extensions tab. If you don't find it, here's a video I found that goes step-by-step through setting up VSCode for Python on MacOS : https://www.youtube.com/watch?v=06I63_p-2A4
Yes it should be downloadable. Just go to the extensions tab and install python from there. Python should work in VS Code Mac.
Thanks for the replies! I looked into extensions and that still ended up being a dead end. I did notice that you two mentioned VS Code while I was strictly looking at the VS IDE. Turns out the Mac version of VS IDE does not support Python from install while the Windows version does. Either way at this point I'm going to use Eclipse haha.
https://visualstudio.microsoft.com/vs/mac/#vs_mac_table

Fake module for autocomplete support Pycharm [duplicate]

When writing Python code using compiled extensions (the OpenCV Python bindings, for example), PyCharm doesn't seem to be aware of their availability. The imports are marked with a grey underline, saying "unresolved reference" as a tooltip, and autocomplete doesn't work, either. (Except for the function names already used in the code.)
This isn't caused by wrong module paths, the code runs without error when started. Also, after I import the modules in a Python shell, autocomplete starts working as expected.
Is there a solution for that or is this an architectural limitation for compiled extensions? Are there any other IDEs that manage to cope with this problem?
The imports are marked with a grey underline, saying "unresolved reference" as a tooltip
This most probably means that PyCharm can't see the module you import. In editing mode, PyCharm relies on availability of Python sources of imported modules. If a module is not written in Python but is a C extension module, PyCharm generates a 'skeleton' that contains function prototypes, and uses it for completion.
In shell mode, PyCharm uses live imported objects for completion, with slightly different results.
Make sure that your OpenCV installation is visible for the Python interpreter you chose for the project (File / Settings / Python interpreter). If the interpreter is correct, try removing and re-adding it (this is time-consuming a bit, sorry).
If nothing helps, file a bug.
I have noticed a difference in pycharm behavior depending on the way to import.
using:
import cv2
the auto completion doesn't work,
while with:
from cv2 import cv2
auto completion works
I had to hardlink the binary into the folder lib-dynload of my interpreter.
$ cd /usr/lib/python3.7/lib-dynload
$ sudo ln /usr/local/lib/python3.7/dist-packages/cv2/python-3.7/cv2.cpython-37m-x86_64-linux-gnu.so cv2.cpython-37m-x86_64-linux-gnu.so
The paths may vary in your environment. I didn't test it on OSX or Windows, but it may work there too. The lib-dynload folder is here:
PyCharm currently does not scan compiled extensions/binaries which are in a path manually added to the interpreter in the IDE. I have filed a bug with Jetbrains in YouTrack. You might want to have a look at it and possibly the discussion I initiated in their discussion forum (link is in the bug description). I'd appreciate if you could vote for this issue to be resolved in YouTrack if you are a PyCharm user facing the same problem.
Try clicking "Reload" button in File | Settings | IDE Settings | Python interpreters. That got it working for me.
In my case on OS X 10.8 and PyCharm 3, IDE was automatically picking different installations of Python. I noticed this in Eclipse Pydev, which picked up the one right one and worked as expected. It was not easy to notice the difference between the two:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python
I follow the instructions under this question:
How to install OpenCV on Windows and enable it for PyCharm without using the package manager
After that it does not work and I reinstall the pycharm ide without any other changes and now it is working perfectly.
I know that this is not the best answer, but after a lot of time wasted and trying different workarounds this was the one that solve my problem, I hope it can help you.
After two days test,I finally fix this issue:
The difference:
Uninstall python 3.7.2,install python 3.7.7.
Change the path where python install.(I strongly doubt that the cause is that my PATH of opencv-python has some Chinese characters.It should have only English).
Then do:
Install the opencv-contrib-python.
I hate to give a "works for me" answer, but maybe the details on my environment will help you identify the problem on your end.
I've never used PyCharm before, but I just did a test on Mac 10.6.6 using PyCharm 1.1.1, with Macports opencv +python26. The autocomplete worked fine for me the first time. I also closed and re-ran PyCharm and was able to autocomplete without doing anything further. I also had no issue with autocomplete for other native extensions I tried like cjson, procname.
.
Perhaps it is a platform-specific issue (Windows?), or a bug affecting an older version of PyCharm?
In my case, include opencv in the path install-opencv-4-on-windows. and add it to the project settings, if none of this works for you, I recommend that you install anaconda change the python interpreter and use the anaconda interpreter.
for this go to : file -> settings -> project:test -> python interpreter and select conda interpreter
if you dont have anaconda you can download at https://www.anaconda.com/
follow the steps in the link python-opencv to install opencv in anaconda

How to uninstall and/or manage multiple versions of python in OS X 10.10.3

I have installed the Python IDE Spyder. For me it's a great development environment.
Some how in this process I have managed to install three versions of Python on my system.These can be located as following:
Version 2.7.6 from the OS X Terminal;
Version 2.7.8 from the Spyder Console; and
Version 2.7.9rc1 from an IDL window.
The problem I have is (I think) that the multiple versions are preventing Spyder from working correctly.
So how do I confirm that 2.7.6 is the latest version supported by Apple and is there a simple way ('silver bullet') to remove other versions from my system.
I hope this is the correct forum for this question. If not I would appreciate suggestions where I could go for help.
I want to keep my life simple and to develop python software in the Spyder IDE. I am not an OS X guru and I really don't want to get into a heavy duty command line action. To that end I just want to delete/uninstall the 'unofficial versions' of Python. Surely there must be an easy way to do this - perhaps 'pip uninstall Python-2.7.9rc1' or some such. The problem is that I am hesitant to try this due to the fear that it will crash my system.
Help on this would be greatly appreciated.
(Spyder dev here) There is no simple way to do what you ask for, at least for the Python version that comes with Spyder.
I imagine you downloaded and installed our DMG package. That package comes with its own Python version as part of the application (along with several important scientific packages), so it can't be removed because that would imply to remove Spyder itself :-)
I don't know how you installed IDL(E?), so I can't advise you on how to remove it.

Failed to load OpenCL runtime - OpenCV3 Python

I have a program that processes videos using foreground detection in OpenCV 2.4.9/python/on windows and packaged for a windows executable using py2exe. I recently updated opencv to opencv3 and repackaged my program. When i run on my computer (with opencv3 installed locally) everything goes fine.
However, when a user goes and downloads the program and runs it on another computer, they get the warning
Failed to load OpenCL runtime
This just seems to be just a warning, and i can detect no performance issues.
I have a couple options. I can just suppress this specific warning in a try statement, or i can somehow turn off the OpenCL on my computer for packaging the program. Suggestions on either strategy would be appreciated. Anything i am overlooking? To my understanding the OpenCL library is for acceleration using GPU.
Thanks,
the solution will be compiling the OpenCV libs without OpenCL and then link them to your application
I had encounter the same problem, here's my solution:
go to the Intel website and download the OpenCL library, then unzip it
run the install.sh file
If your install fails because of update-alternatives errors, maybe it's because you are using Ubuntu/Debian distro and the Intel install package has a wrong setting with it.
To solve this, xfanzone did a very good job on this. Take a look here.
download the patch zip file and patch your OpenCL package
install it again, now it should work fine
If you just don't need to use OpenCL, you can set the environment var as below:
export OPENCV_OPENCL_RUNTIME=999
Sometimes, if you want to turn on the opencl:
export OPENCV_OPENCL_RUNTIME=

How to install Python on mac os x and windows with Aptana Studio?

How do I get python to work with aptana studio?
I've downloaded a bunch of stuff, but none of them seem to give me a straight text editor where I can interpret code into an executable type thing. I know there's interactive mode in IDLE, but I want to actually use an editor. So I downloaded the pydev extensions for Aptana studio, but it wants me to configure a python interpreter (so I guess it actually doesn't have one). Where can I find a straight python interpreter that will work with this? or another IDE?
It's easier than you think. First, there's a version of python on your machine by default. It's kind of out of date, though.
MacPorts is a nice method to get lots of good stuff.
ActiveState has a Python Mac package downloadable for free.
Python.org will lead you to some other options as well.
To add the current Python version on Mac:
Add new interpreter via Aptana Studio 3/Preferences/PyDev/Interpreter-Python.
Give it name (check version using the Terminal and then python or /usr/bin/python.
Then add the path (2.7 in my case): /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
If you install your own (2.6 in my case) use the following path instead:
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
Don't forget to hit the "Apply" button...
Idle has a complete text editor -- open a "new window" and type away. Be sure to save it before you run it.
What didn't you like about the IDLE editor?
Also, look at Komodo Edit for Mac OS X. Very nice.
For windows, I'd recommend the aforementioned ActivePython. Mainly because it comes with Python win32, which you're going to end up installing anyway.
Secondly, if you're coming from the world of Java and C#, you might be expecting too much out of your IDE. I eventually found that more powerful IDEs just made things more difficult than they helped. So my advice is to try to go with something simple. In other words, go with something that will let you jump in and start coding rather than bugging you with a lot of features you probably won't need anyway. :-)
EDIT: One other thing, find and install pip. It makes installing python packages so much easier.
A lot of the sites in the Windows list mirror the Mac list.
Python.org has Win32 and Win64 installers.
ActiveState has a free Python Win32 package downloadable for free. There is no Win64 version (yet?).
PyWin32 is a Python package with extra modules for interfacing with Windows. This is not Python itself. These haven't been updated for Python 3.0, though. Despite the name, there is a Win64 version for Python 2.6 on this site.
On Mac OS X Leopard and Tiger, Python is already installed.
On Mac, I've tried a few editor. Textmate is my current choice. If you're looking for a free one, I really liked Xcode. But you'll have to run your script from the command line.
If you want a cross-platform environment, you could try Eclipse and the pydev extension. So you don't get lost between the two platform.
For Windows Operating system,
If you want to work with python using Aptana Studio. You have to do some simple basic settings with the interpreter.
For detailed step by step guide. You can follow this website link
http://www.infoknol.com/aptana-python-setup-guide/

Categories