static public bool rCUDACommand(List <string> commandList) { UnsetRcudaEnv(); bool result = true; SystemCall runrCuda = new SystemCall(); // foreach (var cmd in commandList) { // runrCuda.CommandText = @"/bin/bash"; // runrCuda.Parameters = String.Format (@" -c ""{0}""", cmd); // runrCuda.CommandExecute (); // if (runrCuda.StandError.Trim () != "") { // result = false; // } // } string cmdStr = String.Join("\n", commandList); runrCuda.CommandText = @"/bin/bash"; runrCuda.Parameters = String.Format(@"-c ""{0}""", cmdStr); runrCuda.CommandExecute(); Console.WriteLine(runrCuda.StandError); if (runrCuda.StandError.Trim() != "") { result = false; } return(result); }
bool G_RestartAgent() { SystemCall restartAgent = new SystemCall(); restartAgent.CommandText = @"/bin/bash"; restartAgent.Parameters = @"/etc/init.d/matrix-agent restart"; restartAgent.EnableStandOutput = false; restartAgent.EnableStandError = false; restartAgent.CommandExecute(); return(true); }
static public void UnsetRcudaEnv() { SystemCall getRcudaEnv = new SystemCall(); getRcudaEnv.CommandText = @"/bin/bash"; getRcudaEnv.Parameters = @"-c ""printenv | grep RCUDA | awk -F= '{ print $1 }'"""; getRcudaEnv.CommandExecute(); String output = getRcudaEnv.StandOutput; var variables = output.Split('\n'); foreach (var variable in variables) { if (variable.Trim() != "") { SystemCall unsetEnv = new SystemCall(); unsetEnv.CommandText = @"/bin/bash"; unsetEnv.Parameters = String.Format(@"-c ""unset {0}""", variable); } } }
static public List <Dictionary <String, String> > CollectGpuInfo(String agentId, String cudaPath, String nvidiaSmiPath) { String gpuXmlOutput = String.Empty; if (Configuration.GpuDependencyCheck(cudaPath, nvidiaSmiPath)) { SystemCall sysCall = new SystemCall(); sysCall.CommandText = @"/bin/bash"; sysCall.Parameters = String.Format(@" -c ""{0} -q -x | tail -n +3""", nvidiaSmiPath); MatrixLibrary.log.Debug(sysCall.Parameters); if (sysCall.CommandExecute()) { gpuXmlOutput = sysCall.StandOutput; //MatrixLibrary.log.Debug (gpuXmlOutput); //MatrixLibrary.log.Debug (sysCall.StandError); } } else { MatrixLibrary.log.Info("Info: Cuda Path or Nvidia-SMI doesn't find"); } return(ParseGpuXmlInfo(agentId, gpuXmlOutput)); }