diff --git a/src/com/sheepit/client/standalone/ListGpuParameterHandler.java b/src/com/sheepit/client/standalone/ListGpuParameterHandler.java new file mode 100644 index 0000000..66f603e --- /dev/null +++ b/src/com/sheepit/client/standalone/ListGpuParameterHandler.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2017 Laurent CLOUET + * Author Laurent CLOUET + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; version 2 + * of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package com.sheepit.client.standalone; + +import java.util.List; + +import org.kohsuke.args4j.CmdLineException; +import org.kohsuke.args4j.CmdLineParser; +import org.kohsuke.args4j.OptionDef; +import org.kohsuke.args4j.spi.OptionHandler; +import org.kohsuke.args4j.spi.Parameters; +import org.kohsuke.args4j.spi.Setter; + +import com.sheepit.client.hardware.gpu.GPU; +import com.sheepit.client.hardware.gpu.GPUDevice; + +public class ListGpuParameterHandler extends OptionHandler { + public ListGpuParameterHandler(CmdLineParser parser, OptionDef option, Setter setter) { + super(parser, option, setter); + } + + @Override + public int parseArguments(Parameters params) throws CmdLineException { + List gpus = GPU.listDevices(); + if (gpus != null) { + for (GPUDevice gpu : gpus) { + System.out.println("CUDA Name : " + gpu.getCudaName()); + System.out.println("Model : " + gpu.getModel()); + System.out.println("Memory, MB: " + (int) (gpu.getMemory() / (1024 * 1024))); + System.out.println(); + } + } + + System.exit(0); + return 0; + } + + @Override + public String getDefaultMetaVariable() { + return null; + } +} diff --git a/src/com/sheepit/client/standalone/Worker.java b/src/com/sheepit/client/standalone/Worker.java index 64691a7..59e4e6d 100644 --- a/src/com/sheepit/client/standalone/Worker.java +++ b/src/com/sheepit/client/standalone/Worker.java @@ -88,6 +88,9 @@ public class Worker { @Option(name = "--version", usage = "Display application version", required = false, handler = VersionParameterHandler.class) private VersionParameterHandler versionHandler; + @Option(name = "--show-gpu", usage = "Print available CUDA devices and exit", required = false, handler = ListGpuParameterHandler.class) + private ListGpuParameterHandler listGpuParameterHandler; + @Option(name = "--no-systray", usage = "Don't use systray", required = false) private boolean no_systray = false;