Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory info for different processes #2

Closed
subzerofun opened this issue Mar 12, 2017 · 4 comments
Closed

Memory info for different processes #2

subzerofun opened this issue Mar 12, 2017 · 4 comments

Comments

@subzerofun
Copy link

Thank you very much for this little command line tool – it comes in very handy if you run deep learning projects on your GPU. It's always good to know how much VRAM is available.

What i always was looking for is an OSX GPU monitoring App – where you can see the GPU memory usage for every single process. I'm not going to ask you to write this – don't worry :-). But do you know if this is even possible to write? Is there a Nvidia driver API that could give you detailled info about the VRAM usage?

Could you suggest a documentation where i could look for a solution to this ? I can write Swift and a little Obj-C – i just need a starting point where i can extract the info from.

Thanks for reading!

@phvu
Copy link
Owner

phvu commented Mar 13, 2017

Thanks for your interests, I am glad it is useful.
For anything related to nvidia devices, I think the best way is to use NVML, which also has bindings in Python. nvmlDeviceGetComputeRunningProcesses is likely the function you are looking for.

Probably I can do something about it when I got some time to spare.

@subzerofun
Copy link
Author

Hey i know i already said thanks – but have another one: Thank you :-)

Your tool saved me a lot of trial and error when processing big neural net models models on the GPU. At least now i can roughly estimate how much i can "shove" in the VRAM without crashing processes.

But since i'm the visual type i would like to write a small Swift App that shows you the free memory in the menubar (kinda like iStatMenus, but of course not that detailed).

But i'm just a Swift beginner (little C++ experience, no experience with Obj-C) and have never integrated C++ code in a Swift Project, so i searched for some resources on how to integrate and call C++/C functions and get their values from within a Swift file:
http://www.swiftprogrammer.info/swift_call_cpp.html
http://stackoverflow.com/questions/26805097/call-a-c-function-from-swift
http://stackoverflow.com/questions/35229149/interacting-with-c-classes-from-swift
http://stackoverflow.com/questions/24042774/can-i-mix-swift-with-c-like-the-objective-c-mm-files

I haven't tried it yet though – i thought i ask you before i run into compiler errors. If i follow the guides from the links i should be able to call the main() function and retrieve the string for further processing in Swift. Please correct me if i'm wrong here and what i would have to look out for when i integrate the .cpp and .h files in my Swift project.

Things like: I would need to include the cuda_runtime_api.h – and then also the dependencies from this header?

From cuda_runtime_api.h, line 133 (CUDA 8):

#include "host_defines.h"
#include "builtin_types.h"

Or should i add the whole include folder from my CUDA installation (usr/local/cuda/include)?

Sorry if this sounds amateurish, but i have never worked with C functions in Swift.

But it would be quite useful to know more about this – at least complete a small example like this – so that i know how to do it with more complex C functions.


The command line is good and fine, but sometimes it's better if you can wrap parameter-heavy programs in a user-friendly UI.

For example: If this works, i would like to add a little "free VRAM" bar to a OSX UI that lets you control the execution of the torch project neural style from jcjohnson. And maybe a few more. I'm aware that there are tools out there that do exactly the same in the browser (OS-independent is probably better), but it's an exercise to get to know Swift better.

Of course it would be great if i was experienced enough to directly integrate the torch framework (bundle it) into an OSX App – but that's way beyond what i am able to code now. I only found a torch framework for iOS, but unfortunately the repo owner didn't reply to my question: clementfarabet/torch-ios#25

Here's a screenshot of a (buggy 😬) tool i wrote to manage the CNNMRF workflow:
bildschirmfoto 2016-06-15 um 19 08 20

Typing in every command anew in Terminal can be quite cumbersome after a while. So that UI came in handy to quickly try out different values and instantly see the result. But code-wise it's a mess :-). I'm still learning all of this.


Hope you can help me out a little (not with torch – that's something i have to solve when i'm more experienced) with integrating the main function to Swift!

Thanks for reading and sorry if i wandered off a little bit :-).

@phvu
Copy link
Owner

phvu commented Mar 29, 2017

yea, good luck

@phvu phvu closed this as completed Mar 29, 2017
@subzerofun
Copy link
Author

Hey didn't mean to bore you with an essay about my coding progress there, sorry...

Could you please just answer my question about integrating the .cpp and .h files in a Swift project?

Would i be able to compile the files (cuda-smi.cpp, mm.cu) in XCode and get the info from the main() function of cuda-smi.cpp and convert it to Swift string variable? Or is it more complicated than this because of the nvcc compiler? As i said, i've never tried to work with C functions in Swift.

Or could you point me to a forum/subreddit where i could ask for help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants