theshadow27
Gawd
- Joined
- Sep 7, 2004
- Messages
- 695
I built a test machine to see what a $100 4850 would do, total cost $380. It won't run a CPU client and a GPU client at the same time, and even with the GPU alone it VPU recover crashes every 1.5 WUs. Very annoying, but considering the cost and that is is self-tapping screwed to a piece of sheet metal, I don't care enough to troubleshoot it. Probably something to do with the $30 500w psu...
Anyway, here's the fix. Rather than figuring out why it's crashing, I just watch the terminal output, and if it doesn't report progress after 5 minutes, it restarts the client. Simple like pie
Not a finished product, just a 150 line hack! Cheers, JSD
Anyway, here's the fix. Rather than figuring out why it's crashing, I just watch the terminal output, and if it doesn't report progress after 5 minutes, it restarts the client. Simple like pie
Code:
package gpumon;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Timer;
import java.util.TimerTask;
/**
*
* @author theshadow
*/
public class Main {
static String process;
static Fah fah;
static int restarts = 0;
static final Object wait = new Object();
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
if (args == null || args.length == 0) {
process = "Folding@home-Win32-GPU -advmethods -verbosity 9";
} else if (args.length == 1) {
process = args[0] + " -advmethods -verbosity 9";
System.out.println("No timeout specified, setting to 5 minutes");
} else {
System.err.println("Error, " + args.length + " args...");
for (String s : args) {
System.err.println(s);
}
return;
}
long start, stop;
restart();
while (true) {
start = System.currentTimeMillis();
try {
int i = 0;
for (i = 0; i < 40; i++) {
synchronized (wait) {
// Sleep 10 seconds
wait.wait(10000);
}
System.out.print(".");
if (fah.deltaP()) {
break;
}
}
if (i >= 39) {
System.out.println("Too long to complete step. Restarting...");
fah.shutdown();
restart();
continue;
}
} catch (InterruptedException e) {
}
stop = System.currentTimeMillis();
System.out.print(" (" + (stop - (double) start) / 1000 + " seconds)\n");
}
}
static void restart() throws Exception {
if (fah != null) {
try {
fah.shutdown();
} catch (Exception e) {
}
}
System.out.println("Starting client, n=" + restarts++);
fah = new Fah(process, null, null);
fah.start();
// wait for it to kick in
synchronized (wait) {
wait.wait(30000);
}
System.out.println("Running loop.");
}
static class Fah extends Thread {
int progress = 0;
int deltaProgress = -1;
Process process;
public Fah(String exec, String[] envprops, File directory) throws IOException {
process = Runtime.getRuntime().exec(exec, envprops, directory);
}
@Override
public void run() {
try {
BufferedReader re = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
while ((line = re.readLine()) != null) {
if (line.contains("Completed") && line.trim().endsWith("%")) {
progress = Integer.parseInt(line.split(" ")[2].replaceAll("%", ""));
try {
synchronized (wait) {
wait.notifyAll();
wait.wait(50);
}
} catch (InterruptedException e) {
}
System.out.print("* " + line);
} else {
System.out.println("> " + line);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
public void shutdown() {
process.destroy();
}
/**
* Returns true if we have made progress since the last call of this method
* @return
*/
public synchronized boolean deltaP() {
if(deltaProgress == -1){
deltaProgress = progress;
}
boolean result = (progress - deltaProgress) != 0;
deltaProgress = progress;
return result;
}
@Override
protected void finalize() throws Throwable {
shutdown();
}
}
static void panic() {
System.out.println("Terminal Error... Shutting down");
System.exit(-1);
}
}
Not a finished product, just a 150 line hack! Cheers, JSD