Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WSL support #58

Merged
merged 16 commits into from
Dec 5, 2024
28 changes: 24 additions & 4 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ on:

env:
CUDA_DEVICE_ORDER: PCI_BUS_ID
RUNNER: 10.0.14.248

jobs:
build:
test:
runs-on: ${{ matrix.os }}

strategy:
Expand Down Expand Up @@ -70,10 +69,31 @@ jobs:
source venv/bin/activate
pip install .
python tests/os.py

wsl:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- uses: Vampire/setup-wsl@v4
with:
distribution: Ubuntu-24.04
additional-packages:
python3-pip
python3-venv

- name: test os
shell: wsl-bash -u root {0}
run: |
python3 -m venv venv
source venv/bin/activate
pip install .
python tests/os.py

gpu:
runs-on: self-hosted
container:
image: ${RUNNER}:5000/modelcloud/gptqmodel:compiler_cuda124-torch2.5.1-python311
image: 10.0.14.248:5000/modelcloud/gptqmodel:compiler_cuda124-torch2.5.1-python311
steps:
- uses: actions/checkout@v4

Expand All @@ -85,7 +105,7 @@ jobs:

- name: Find suitable GPU
run: |
gpu_id=$(curl -s "http://${{ needs.check-vm.outputs.ip }}/gpu/get?id=${{ github.run_id }}&timestamp=$(date +%s%3N)&force=1")
gpu_id=$(curl -s "http://10.0.14.248/gpu/get?id=${{ github.run_id }}&timestamp=$(date +%s%3N)&force=1")
echo "CUDA_VISIBLE_DEVICES=$gpu_id" >> $GITHUB_ENV

- name: test gpu
Expand Down
10 changes: 8 additions & 2 deletions device_smi/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,14 @@ def metrics(self):
if platform.system().lower() == "windows":
command_result = _run(["wmic", "cpu", "get", "loadpercentage"]).strip()
command_result = re.sub(r'\n+', '\n', command_result)
result = command_result.split("\n")[1].split(",")
utilization = int(result[0])
try:
result = command_result.split("\n")[1].split(",")
utilization = int(result[0])
except BaseException as e:
print(f"error occurred, command_result: ")
print(f"{command_result}")
print(f"------------")
raise e

command_result = _run(["wmic", "os", "get", "FreePhysicalMemory"]).strip()
command_result = re.sub(r'\n+', '\n', command_result)
Expand Down
2 changes: 1 addition & 1 deletion device_smi/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, cls):

if platform.system().lower() == "linux" or platform.system().lower() == "freebsd" or platform.system().lower() == "solaris" or platform.system().lower() == "sunos":
release_info = self.to_dict(_run(["cat", "/etc/os-release"]).replace("\"", "").lower(), "=")
cls.name = release_info["name"].replace("oracle", "").strip()
cls.name = release_info["name"].replace("oracle", "").replace("gnu/linux", "").strip()

cls.version = release_info["version_id"]
match = re.match(r"(\d+\.\d+)", cls.version)
Expand Down
Loading