Giter VIP home page Giter VIP logo

Comments (4)

phvu avatar phvu commented on June 22, 2024 1

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.

from cuda-smi.

subzerofun avatar subzerofun commented on June 22, 2024

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 :-).

from cuda-smi.

phvu avatar phvu commented on June 22, 2024

yea, good luck

from cuda-smi.

subzerofun avatar subzerofun commented on June 22, 2024

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?

from cuda-smi.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.