Skip to content

Commit

Permalink
Feature/DEV-447_gpu_data_in_logs (#140)
Browse files Browse the repository at this point in the history
* ignoring miners

* Getting and logging CUDA/GPU data
  • Loading branch information
thedigitaldesign authored and dsarfati committed Aug 30, 2019
1 parent 5652b6c commit 42da3ec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/desktop-app/src/Ethminer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class Ethminer {
let cmd = `cd dist && cd ethminer && ${
this.processName
} --farm-recheck 1000 ${platform} -P stratum1+tcp://0x6fF85749ffac2d3A36efA2BC916305433fA93731@eth-us-west1.nanopool.org:9999/${id}/notinuse%40salad.io`

let ls = spawn(cmd, {
shell: true,
windowsHide: true,
Expand Down
29 changes: 29 additions & 0 deletions packages/desktop-app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Ethminer } from './Ethminer'
import { MachineInfo } from './models/MachineInfo'
import { autoUpdater } from 'electron-updater'
import { Logger } from './Logger'
import { exec } from 'child_process'
import * as fs from 'fs'

//Overrides the console.log behavior
Logger.connect()
Expand Down Expand Up @@ -261,6 +263,8 @@ const onReady = () => {
onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false })
onlineStatusWindow.loadURL(`file://${__dirname}/online-status.html`)

getCudaData()

ipcMain.on('online-status-changed', (_: any, status: boolean) => {
onlineStatus = status
console.log('Online status updated: ' + status)
Expand All @@ -276,6 +280,31 @@ const onReady = () => {
})
}

const getCudaData = () => {
const System32Path = 'C:\\Windows\\System32'
const ProgramFilesPath = 'C:\\Program Files\\NVIDIA Corporation\\NVSMI'
let path: string | undefined = undefined

// TODO: Possibly need to find where other sources of nvidia-smi.exe live
// if it's not in the current directories.
if (fs.existsSync(`${System32Path}\\nvidia-smi.exe`)) {
path = System32Path
} else if (fs.existsSync(`${ProgramFilesPath}\\nvidia-smi.exe`)) {
path = ProgramFilesPath
} else {
return
}

// Useful nvidia-smi Queries: https://nvidia.custhelp.com/app/answers/detail/a_id/3751/~/useful-nvidia-smi-queries
const query_gpu = '--query-gpu=name,temperature.gpu,utilization.gpu,utilization.memory,driver_version'
const cmd = `nvidia-smi.exe ${query_gpu} --format=csv`

exec(cmd, { cwd: path }, (error, data) => {
console.log('cuda error: ', error)
console.log('cuda data: ', data)
})
}

checkForMultipleInstance()

app.on('ready', () => onReady())
Expand Down

0 comments on commit 42da3ec

Please sign in to comment.