Skip to content

Weekly CI run with NVidia GPU hardware #24491

Closed

Description

@ogrisel

Now that #22554 was merged in main, it would be great to find a a way to run a weekly scheduled job to run the scikit-learn main test on a CI worker with an NVidia GPU and CuPy.

In case of failure, it could create a report as dedicated issues as we do for other scheduled jobs:

Maybe @betatim has a plan and connections to do that? ;)

Activity

  1. ogrisel commented on Sep 21, 2022

    @ogrisel
    MemberAuthor

    Other opensource projects like dask and numba have accounts on https://gpuci.gpuopenanalytics.com/ for instance. Not sure what is the procedure to get scikit-learn accepted there (even with a limited quota of a few GPU hours per month).

  2. betatim commented on Sep 23, 2022

    @betatim
    Member

    Ive started looking into this

  3. ogrisel commented on Jun 1, 2023

    @ogrisel
    MemberAuthor

    As discussed during the triaging meeting, we could use https://docs.cirun.io/ which is free for open source projects.

    We would then need to register a credit card for our numfocus account on an AWS or Google Cloud.

    If we do a few weekly runs, that should be cheap enough.

    If we want to make it possible to trigger a GPU run from a git commit message in a PR we need to make sure that cirun would not spawn a GPU instance just to skip the build if the flag is not present in the git commit message, but it might be doable.

  4. thomasjpfan commented on Jan 29, 2024

    @thomasjpfan
    Member

    Progress update as of a few weeks ago: I got cirun.io working on my fork, but I ran into an issue with it stalling with PyTorch. I suspect it was because I was using GPUs that were too old, but I ran out of time to debug.

    To reduce cost:

    • I had GitHub Actions build the wheel and ship it over to cirun.io.
    • I had a prebuilt image with the cuda dependencies installed.
  5. ogrisel commented on Jan 29, 2024

    @ogrisel
    MemberAuthor

    Great news! Thanks very much for the progress report @thomasjpfan.

  6. betatim commented on Feb 7, 2024

    @betatim
    Member

    Is there a way to help out/join in? I think having a CI sooner rather than later would be really useful.

    I think cirun is our only option

  7. ogrisel commented on Feb 7, 2024

    @ogrisel
    MemberAuthor

    @thomasjpfan do you want someone else to try to takeover from your work in https://github.com/thomasjpfan/scikit-learn/tree/cirun_gpu if you don't have time to finalize this work yourself?

  8. thomasjpfan commented on Feb 7, 2024

    @thomasjpfan
    Member

    The latest work is at https://github.com/thomasjpfan/scikit-learn/tree/cirun_gcp (GCP)

    I'll take another took at it this weekend. If I do not have a PR by Monday, then let's schedule a call so I can do a handoff.

  9. thomasjpfan commented on Feb 7, 2024

    @thomasjpfan
    Member

    After a few more iterations, it works now! https://github.com/thomasjpfan/scikit-learn/actions/runs/7820229387/job/21334434689

    Next step is to to wrap it up into our workflow for triggering cirun.

  10. thomasjpfan commented on Feb 7, 2024

    @thomasjpfan
    Member
  11. lesteve commented on Feb 8, 2024

    @lesteve
    Member

    My understanding is that using custom Github runners exposes you to a lot of security issues, I am curious to know if there is any thoughts on how to mitigate this in scikit-learn, e.g. by only allowing a scheduled weekly run or some other way that make sure that running the GPU workflow is fully controlled by maintainers.

    For exemple, according to Hardening for self-hosted runners "self-hosted runners should almost never be used for public repositories".

    Also using a custom github runner was a key aspect in the PyTorch suppply-chain article

    I had a quick look at https://cirun.io and I could not find any mention about security there ...

  12. thomasjpfan commented on Feb 8, 2024

    @thomasjpfan
    Member

    I'm +1 on at least having a weekly run.

    The hard part comes from PRs. I proposed using a "run-gpu-ci" GitHub label to trigger the CI. Here are the details:

    1. When a maintainer adds a "run-gpu-ci" label, it will trigger a wheel build on the PR itself.
    2. The wheel is send over a "run on gpu" workflow using workflow_dispatch.
      • This workflow type runs in the context of the main branch, so the only adjustable input is the wheel itself.
      • With workflow_dispatch only the "cirun.io" configuration on the main branch is used. PRs can not configure the runner itself.
    3. The "run gpu" removes the "run-gpu-ci" label and sends the wheel to cirun for testing. (pytest --pyargs sklearn)

    With the above approach, it requires a maintainer to add a "run-gpu-ci" label each time they want to trigger a gpu ci run. In the end, it is using labels to implement "Require approval for all outside collaborators’" just for the GPU runner.

    There are two security concerns:

    1. We make sure that only the scikit-learn team can add the "run-gpu-ci" label.
    2. Before adding the label, the reviewer needs to make sure the code does not do anything malicious. Specifically, one can still run arbitrary code in a test.

    I say 2 is the bigger concern, because we can miss something. @aktech What are the security concerns with running arbitrary code using cirun.io?

  13. 8 remaining items

  14. aktech commented on Mar 15, 2024

    @aktech

    I can answer a couple of questions:

    where does the third-campus-393023:scikit-learn-gpu-v4 machine image come from?

    This is the custom image @thomasjpfan created in his GCP account with nvidia drivers installed (and maybe something else too).

    will cirun spin-up a costly GPU VM just to run the build condition (e.g. check the presence of the label on the PR) or will the GPU VM start (and be build) only if the trigger condition evaluates to true?

    You can do this by checking if GPU tests should run or not in GitHub hosted runner (non-gpu) and then trigger the job with GPU if required, example:

    Screenshot 2024-03-15 at 1 42 52 pm

    Ref: https://github.com/scverse/anndata/actions/runs/8277985942

  15. thomasjpfan commented on Mar 15, 2024

    @thomasjpfan
    Member

    where does the third-campus-393023:scikit-learn-gpu-v4 machine image come from?

    This is a custom image on my GCP account with conda + nvidia drivers installed. This makes start up times much faster, at the cost of storing an image in GCP.

    do we need the .devcontainer/devcontainer.json as part of the CI itself, or was it just for local dev?

    I mixed up testing Codespaces into my GPU+CI testing branch.

    Is the use of workflow_dispatch still relevant?

    This was my mistake, the GitHub event should either be workflow_run or pull_request_target. I think these events are still required because of the security concerns. I feel like pull_request_target could be good enough, but that needs some testing. I did not configured this in my experimentation.

    CIRun does have access controls, but I do not think it works for our workflow of PRs from external users. Also, we'll need

  16. ogrisel commented on Mar 15, 2024

    @ogrisel
    MemberAuthor

    Also, we'll need

    It seems that you did not finish your sentence.

  17. thomasjpfan commented on Mar 15, 2024

    @thomasjpfan
    Member

    It seems that you did not finish your sentence.

    I reordered the paragraphs and did not remove the last part in the editing. 😅

  18. ogrisel commented on Mar 18, 2024

    @ogrisel
    MemberAuthor

    where does the third-campus-393023:scikit-learn-gpu-v4 machine image come from?

    This is a custom image on my GCP account with conda + nvidia drivers installed. This makes start up times much faster, at the cost of storing an image in GCP.

    Could you please push the Dockerfile to your branch to make it more convenient to update this container from time to time when dependencies are updated?

  19. thomasjpfan commented on Mar 28, 2024

    @thomasjpfan
    Member

    I did not use a Dockerfile to create the custom image on GCP. I had a running instance, installed the Nvidia drivers + conda, and then created a clone.

    I do not know if there is a way to create a custom image with Docker on GCP.

    REF: https://docs.cirun.io/custom-images/cloud-custom-images#gcp-custom-images

  20. ogrisel commented on Apr 4, 2024

    @ogrisel
    MemberAuthor

    Why would a custom VM image be a better solution that using a custom docker image in a standard GCP image?

  21. aktech commented on Apr 4, 2024

    @aktech

    Why would a custom VM image be a better solution that using a custom docker image in a standard GCP image?

    It's not about which one is better, either can be done with different levels of complexity. You can build a custom docker image, but in that case you'll have to do these things:

    • Still have to create a custom image with NVIDIA Container Toolkit installed, this will help in building and running GPU-accelerated containers.
    • Run your tests inside docker, which will add more complexity in the scikit-learn CI.
  22. moved this to Discussion in Array APIon May 17, 2024
  23. ogrisel commented on May 28, 2024

    @ogrisel
    MemberAuthor

    For the record, GitHub has recently announced a public beta for GitHub-hosted runners with GPU capabilities:

    However, the scikit-learn organization does not seem to have the ability to create such runners with its GitHub Team plan at the moment.

    EDIT: I wrote the above too quickly, apparently @betatim figured it out: we need to use a "partner image" from NVIDIA when creating the runner to see the GPU option.

  24. moved this from Discussion to Done in Array APIon Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions