Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions .github/workflows/translate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
permissions:
contents: write

concurrency:
group: translate-${{ github.ref }}
cancel-in-progress: true

jobs:
prepare-matrix:
name: Prepare Translation Matrix
Expand Down Expand Up @@ -86,6 +90,8 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download All Translations
uses: actions/download-artifact@v4
Expand All @@ -95,17 +101,28 @@ jobs:
merge-multiple: true

- name: Commit and Push
env:
BRANCH: ${{ github.ref_name }}
run: |
git config --global user.name "DataBoySu's Readme Translator"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

# Ensure we're on the correct branch and have full history
git fetch origin "$BRANCH"
git checkout "$BRANCH"

git add locales/*.md
git commit -m "docs: update translations" || echo "No changes to commit"

# Retry logic for concurrent pushes
for i in {1..5}; do
git pull --rebase
if git push; then exit 0; fi
echo "Push failed, retrying in 5s..."

# Retry logic for pushes that fail due to remote updates
for i in 1 2 3 4 5; do
git pull --rebase origin "$BRANCH" || true
if git push origin "$BRANCH"; then
echo "Push succeeded"
exit 0
fi
echo "Push failed (attempt $i), retrying in 5s..."
sleep 5
done
echo "Push failed after retries"
exit 1
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<!-- HTML_BLOCK: no change to url; output entire as it is... -->
![License](https://img.shields.io/badge/license-MIT-orange.svg)
![Python](https://img.shields.io/badge/python-3.10%2B-pink)
![Version](https://img.shields.io/badge/version-1.2.3-green)
![Platform](https://img.shields.io/badge/platform-Windows10/11-blue)
![Version](https://img.shields.io/badge/version-1.3.0-green)
![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-blue)
![cuda 12.x](https://img.shields.io/badge/CUDA-12.x-0f9d58?logo=nvidia)

## Gallery
Expand Down Expand Up @@ -109,8 +109,8 @@ Contributions are welcome! Main future points to cover would be:
- **Containerization**: Official Docker support for easy deployment in containerized environments.
- **Remote Access**: SSH tunneling integration and secure remote management.
- **Cross-Platform**:
- [ ] Linux Support (Ubuntu/Debian focus).
- [ ] macOS Support (Apple Silicon monitoring).
- [x] Linux Support (Ubuntu/Debian focus).
- [x] macOS Support (Apple Silicon monitoring).
- **Hardware Agnostic**:
- [ ] AMD ROCm support.
- [ ] Intel Arc support.
Expand All @@ -122,11 +122,11 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for how to get involved.

## Requirements

- **OS**: Windows 10/11
- **OS**: Windows 10/11, Linux, macOS
- **Python**: 3.10+
- **Hardware**: NVIDIA GPU with installed drivers.
- **CUDA**: Toolkit 12.x (Strictly required for Benchmarking/Simulation features).
- *Note: If CUDA 12.x is not detected, GPU-specific benchmarking features will be disabled.*
- **Hardware**: NVIDIA GPU (all platforms), Apple Silicon (macOS), or CPU-only.
- **CUDA**: Toolkit 12.x (Recommended for Benchmarking/Simulation on NVIDIA).
- *Note: If CUDA/MPS is not detected, some benchmarking features may be disabled.*

---

Expand Down Expand Up @@ -159,16 +159,23 @@ Best for development and stress testing.

### Quick Start

1. **Download** the latest release or clone the repo.
1. **Download** or clone the repository.
2. **Run Setup**:

```powershell
.\setup.ps1
```
**Windows**:
```powershell
.\setup.ps1
```

**Linux/macOS**:
```bash
chmod +x setup.sh
./setup.sh
```

3. **Launch**:

```powershell
```bash
# Start the web dashboard (Standard/Full)
python health_monitor.py web

Expand Down
149 changes: 78 additions & 71 deletions health_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,56 +388,60 @@ def _format_gpu_grid(gpus, total_width: int = None):
def _run_app(config_path, port, nodes, once, web_mode=False, cli_mode=False):
"""Helper to run main application logic."""
# If the user requested admin mode via --admin in argv, and the process is not elevated,
# attempt to relaunch elevated (Windows UAC). This project targets Windows only,
# attempt to relaunch elevated.
try:
import sys
import platform
import os
import subprocess

def _is_elevated():
try:
import ctypes
return bool(ctypes.windll.shell32.IsUserAnAdmin())
except Exception:
return False
if platform.system() == 'Windows':
try:
import ctypes
return bool(ctypes.windll.shell32.IsUserAnAdmin())
except Exception:
return False
else:
return os.getuid() == 0

if '--admin' in (sys.argv[1:] if len(sys.argv) > 1 else []) and not _is_elevated():
# Attempt relaunch elevated on Windows using ShellExecuteW or PowerShell Start-Process
try:
import ctypes
import subprocess
params = '"' + os.path.abspath(sys.argv[0]) + '"'
other_args = [a for a in sys.argv[1:]]
if other_args:
params += ' ' + ' '.join(str(a) for a in other_args)

if platform.system() == 'Windows':
# Attempt relaunch elevated on Windows
try:
import ctypes
params = '"' + os.path.abspath(sys.argv[0]) + '"'
other_args = [a for a in sys.argv[1:]]
if other_args:
params += ' ' + ' '.join(str(a) for a in other_args)

ret = ctypes.windll.shell32.ShellExecuteW(None, 'runas', sys.executable, params, None, 1)
try:
ok = int(ret) > 32
except Exception:
ok = False
if ok:
print('Relaunching elevated, exiting original process')
try: os._exit(0)
except Exception: pass
if int(ret) > 32:
os._exit(0)
except Exception:
def _ps_quote(s):
return "'" + str(s).replace("'", "''") + "'"
ps_args = [os.path.abspath(sys.argv[0])] + list(sys.argv[1:])
arglist_literal = ','.join(_ps_quote(a) for a in ps_args)
ps_cmd = [
'powershell', '-NoProfile', '-NonInteractive', '-Command',
f"Start-Process -FilePath '{sys.executable}' -ArgumentList {arglist_literal} -Verb RunAs"
]
# Fallback to powershell if ShellExecuteW fails
try:
proc = subprocess.run(ps_cmd, capture_output=True, text=True, timeout=15)
if proc.returncode == 0:
try: os._exit(0)
except Exception: pass
def _ps_quote(s):
return "'" + str(s).replace("'", "''") + "'"
ps_args = [os.path.abspath(sys.argv[0])] + list(sys.argv[1:])
arglist_literal = ','.join(_ps_quote(a) for a in ps_args)
ps_cmd = [
'powershell', '-NoProfile', '-NonInteractive', '-Command',
f"Start-Process -FilePath '{sys.executable}' -ArgumentList {arglist_literal} -Verb RunAs"
]
subprocess.run(ps_cmd, capture_output=True, text=True, timeout=15)
os._exit(0)
except Exception:
pass
except Exception:
pass
else:
# POSIX relaunch with sudo
try:
args = ['sudo', sys.executable, os.path.abspath(sys.argv[0])] + sys.argv[1:]
# Ensure we don't end up in an infinite loop if sudo fails or doesn't grant root
if 'SUDO_COMMAND' not in os.environ:
os.execvp('sudo', args)
except Exception:
pass
except Exception:
pass

Expand Down Expand Up @@ -484,42 +488,43 @@ async def main():
@click.pass_context
def cli(ctx, config, port, update, admin):
"""MyGPU: Real-time GPU and system health monitoring."""
# If the user requested admin mode, attempt to relaunch this process elevated
# on platforms that support elevation (Windows -> UAC, POSIX -> sudo).
# If admin requested and not already elevated, attempt to relaunch elevated
def _is_elevated():
try:
import ctypes
return bool(ctypes.windll.shell32.IsUserAnAdmin())
except Exception:
return False
import platform
import os
if platform.system() == 'Windows':
try:
import ctypes
return bool(ctypes.windll.shell32.IsUserAnAdmin())
except Exception:
return False
else:
try:
return os.getuid() == 0
except Exception:
return False

def _relaunch_elevated():
try:
import sys
import os
import subprocess
script = os.path.abspath(sys.argv[0])
args = sys.argv[1:]
if '--admin' not in args:
args = args + ['--admin']
import sys
import os
import platform
import subprocess
script = os.path.abspath(sys.argv[0])
args = sys.argv[1:]
if '--admin' not in args:
args = args + ['--admin']

if platform.system() == 'Windows':
try:
import ctypes
params = '"' + script + '"'
if args:
params += ' ' + ' '.join(str(a) for a in args)
ret = ctypes.windll.shell32.ShellExecuteW(None, 'runas', sys.executable, params, None, 1)
try:
ok = int(ret) > 32
except Exception:
ok = False
if ok:
print('Relaunching elevated, exiting original process')
try: os._exit(0)
except SystemExit: raise
except Exception: pass
except Exception as e:
# PowerShell fallback if ShellExecuteW is not possible
if int(ret) > 32:
os._exit(0)
except Exception:
# PowerShell fallback
try:
def _ps_quote(s):
return "'" + str(s).replace("'", "''") + "'"
Expand All @@ -529,17 +534,19 @@ def _ps_quote(s):
'powershell', '-NoProfile', '-NonInteractive', '-Command',
f"Start-Process -FilePath '{sys.executable}' -ArgumentList {arglist_literal} -Verb RunAs"
]
proc = subprocess.run(ps_cmd, capture_output=True, text=True, timeout=15)
if proc.returncode == 0:
try: os._exit(0)
except Exception: pass
subprocess.run(ps_cmd, capture_output=True, text=True, timeout=15)
os._exit(0)
except Exception:
pass
else:
# POSIX relaunch with sudo
try:
sudo_args = ['sudo', sys.executable, script] + args
if 'SUDO_COMMAND' not in os.environ:
os.execvp('sudo', sudo_args)
except Exception as e:
print(f'Relaunch elevation error: {e}')

except Exception as e:
print('Relaunch elevation error:', e)

# If admin requested and not already elevated, attempt to relaunch elevated
try:
if admin and not _is_elevated():
_relaunch_elevated()
Expand Down
2 changes: 1 addition & 1 deletion monitor/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "1.3.0"
__version__ = "1.4.0"
__author__ = "DataBoySu"
__license__ = "MIT"
Loading