Using the: java.lang.management.ManagementFactory and com.sun.management.OperatingSystemMXBean libraries, I was able to read the CPU and RAM usage of my pc. Now I would like to be able to read the Graphics Processing Unit (GPU) usage as well. I would like it to work with NVIDIA and Intel GPUs. Is this possible in Processing? Does anyone have an example on how to do this?
I have tried to make it work with the jSensors library, but Iâm not experienced enough to know how to import the library in my sketch. The readme file it not very clear about this either.
For the CPU usage, everything worked rightaway, I could just do:
Although I get the warning âNo library found for com.sun.managementâ, everything seems to work just fine. Now, how would I achieve the same for GPU? How to import the library?
It appears that there used to be a .jar download but the URL is no longer working. Otherwise, you could drag-and-drop the libraryâs .jar onto your sketch.
The libraryâs README suggests adding it as a maven dependency â this is wholly possible but youâll need to migrate your project to an IDE (other than the PDE) (which I recommend anyway), and create a Maven project there.
Thanks for the reply @micycle, I appreciate any help.
I am using Atom in combination with the âprocessingâ package from âbleikampâ to compile my project in Windows 10.
I canât seem to find the .jar file and Iâm not sure how to create a Maven dependency. Would you be so kind to help me with that? Do I have to copy this file to the same folder as my .pde files?
Iâm making a project which is rendered using the OPENGL renderer of processing, making use of my GPU. I would like to be able to keep track of my hardware usage.
As @hamoid mentioned, the jar file is there. I downloaded âjSensors-2.1.1-jar-with-dependencies.jarâ and put it in my sketchâs âlibrariesâ folder, which I just created. I renamed to file to âjSensors.jarâ, but when I try to âimport jSensors.jarâ at the beginning of my sketch (called Testproject.pde), I get the following error:
" No library found for jSensors
Libraries must be installed in a folder named âlibrariesâ inside the sketchbook folder (see the Preferences window). Testproject.pde:0:0:0:0: The package ďż˝jSensorsďż˝ does not exist. You might be missing a library. "
Hi, inside your sketch folder, create a folder called code and place the jar file there. No need to rename it. The processing IDE automatically creates this folder when you drop a jar file into the IDE.
Thank you @hamoid , that works. I had to import the java.util.List librart as well. Now I can print the cpu model name, like this:
import com.profesorfalken.jsensors.model.components.Components;
import java.util.List;
Components components;
void setup(){
components = JSensors.get.components();
size(1000, 600, OPENGL);
}
void draw(){
background(80);
List<Cpu> cpus = components.cpus; // works
for (final Cpu cpu : cpus) {
println(cpu.name);
}
List<Gpu> gpus = components.gpus; // doesn't work
for (final Gpu gpu : gpus) {
println(gpu.name);
}
}
But I cannot print the load of the cpu. How do I do that? Also, when I try to print the name of the gpu, it is not detected but doesnât give an error either. Do you know what the problem is?
JFTR you never need to use Maven as a build system to use a JAR from Maven. Simply search for what you want at https://search.maven.org and choose the download JAR option (being careful to look for any additional dependencies as well). There is also a download JAR with dependencies option but Iâd be careful with that.