You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
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.
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".
The hard part comes from PRs. I proposed using a "run-gpu-ci" GitHub label to trigger the CI. Here are the details:
When a maintainer adds a "run-gpu-ci" label, it will trigger a wheel build on the PR itself.
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.
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:
We make sure that only the scikit-learn team can add the "run-gpu-ci" label.
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?
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:
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
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?
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.
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.
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.
Activity
ogrisel commentedon Sep 21, 2022
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).
betatim commentedon Sep 23, 2022
Ive started looking into this
ogrisel commentedon Jun 1, 2023
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.
thomasjpfan commentedon Jan 29, 2024
Progress update as of a few weeks ago: I got
cirun.ioworking 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:
cirun.io.ogrisel commentedon Jan 29, 2024
Great news! Thanks very much for the progress report @thomasjpfan.
betatim commentedon Feb 7, 2024
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
ogrisel commentedon Feb 7, 2024
@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?
thomasjpfan commentedon Feb 7, 2024
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.
thomasjpfan commentedon Feb 7, 2024
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.
thomasjpfan commentedon Feb 7, 2024
It also works with T4s: https://github.com/thomasjpfan/scikit-learn/actions/runs/7820372944/job/21334925253 it looks to spin up faster, because there are more T4s available.
lesteve commentedon Feb 8, 2024
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 ...
thomasjpfan commentedon Feb 8, 2024
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:
workflow_dispatch.workflow_dispatchonly the "cirun.io" configuration on themainbranch is used. PRs can not configure the runner itself.cirunfor 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:
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?8 remaining items
aktech commentedon Mar 15, 2024
I can answer a couple of questions:
This is the custom image @thomasjpfan created in his GCP account with nvidia drivers installed (and maybe something else too).
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:
Ref: https://github.com/scverse/anndata/actions/runs/8277985942
thomasjpfan commentedon Mar 15, 2024
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.
I mixed up testing Codespaces into my GPU+CI testing branch.
This was my mistake, the GitHub event should either be
workflow_runorpull_request_target. I think these events are still required because of the security concerns. I feel likepull_request_targetcould 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 needogrisel commentedon Mar 15, 2024
It seems that you did not finish your sentence.
thomasjpfan commentedon Mar 15, 2024
I reordered the paragraphs and did not remove the last part in the editing. 😅
ogrisel commentedon Mar 18, 2024
Could you please push the
Dockerfileto your branch to make it more convenient to update this container from time to time when dependencies are updated?thomasjpfan commentedon Mar 28, 2024
I did not use a
Dockerfileto 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
aktech commentedon Mar 28, 2024
I don't think it's possible to generate VM images from Dockerfile, the last I checked. To programmatically generate VM images you can use something like packer: https://developer.hashicorp.com/packer/integrations/hashicorp/googlecompute/latest/components/builder/googlecompute
Example: https://github.com/actions/runner-images/blob/98d2bcc93e055d8892f9446e72a4da66b334bfb1/images/ubuntu/templates/ubuntu-22.04.pkr.hcl
ogrisel commentedon Apr 4, 2024
Why would a custom VM image be a better solution that using a custom docker image in a standard GCP image?
aktech commentedon Apr 4, 2024
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:
ogrisel commentedon May 28, 2024
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.