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 simple workflow to test npu image on github ci. #391

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
53 changes: 53 additions & 0 deletions .github/workflows/npu_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: npu_test

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
- v0.2.x
paths:
- "**/*.py"
- .github/workflows/npu_test.yml
pull_request:
branches:
- main
- v0.2.x
paths:
- "**/*.py"
- .github/workflows/npu_test.yml

# Declare permissions just read content.
permissions:
contents: read

jobs:
test-cpu-arch:
runs-on: [self-hosted, npu-0]
steps:
- name: verify host cpu architecture.
run: |
lscpu
ray:
runs-on: [self-hosted, npu-0]
env:
HTTP_PROXY: ${{ secrets.PROXY_HTTP }}
HTTPS_PROXY: ${{ secrets.PROXY_HTTPS }}
NO_PROXY: "localhost,127.0.0.1"
HF_HUB_ENABLE_HF_TRANSFER: 1
container:
image: chendong136/verlnpu:ubuntu20.04-py310-cann8.0.0.beta1-ray2.42-torch-npu2.5.1rc1
volumes:
- /usr/local/Ascend/driver:/usr/local/Ascend/driver
options: --privileged --shm-size=10g
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Install the current repository
run: |
pip install --upgrade "ray>=2.40.0"
- name: Running ray tests that need NPUs
run: |
pytest -s tests/npu/test_npu_worker.py
46 changes: 46 additions & 0 deletions tests/npu/test_npu_worker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest
import ray
import torch


@pytest.fixture
def ray_cluster_with_npus():
# Assume in the NPU environment.
ray.init()
yield
ray.shutdown()


@ray.remote(resources={"NPU": 1})
class Worker:

def __init__(self):
pass

def test_torch_npu_avalable(self):
available = False
try:
import torch_npu
available = torch.npu.is_available()
except Exception as e:
pass
return available


def test_torch_npu(ray_cluster_with_npus):
worker = Worker.remote()
assert ray.get(worker.remote())
Loading