Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 620eceb

Browse files
committedDec 1, 2022
bitbucket: add GPU examples
- fixes iterative/cml#1015 - fixes #349
1 parent dbfee41 commit 620eceb

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed
 

‎content/docs/ref/runner.md

+9
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ Any [generic option](/doc/ref) in addition to:
7878
need to write your code to save intermediate results to take advantage of
7979
this).
8080

81+
### Bitbucket
82+
83+
- **GPU support**.
84+
85+
See
86+
[the guide on self-hosted Bitbucket runners](/doc/self-hosted-runners?tab=Bitbucket)
87+
to work around
88+
[Bitbucket's lack of native GPU support](https://jira.atlassian.com/browse/BCLOUD-21459).
89+
8190
## Examples
8291

8392
### Using `--cloud-permission-set`

‎content/docs/self-hosted-runners.md

+51-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ train-and-report:
116116
```
117117
118118
</tab>
119-
<tab title="Bitbucket">
119+
<tab title="Bitbucket (no GPU)">
120120
121121
```yaml
122122
pipelines:
@@ -134,7 +134,6 @@ pipelines:
134134
- step:
135135
runs-on: [self.hosted, cml.runner]
136136
image: iterativeai/cml:0-dvc2-base1
137-
# GPU not yet supported, see https://github.com/iterative/cml/issues/1015
138137
script:
139138
- pip install -r requirements.txt
140139
- python train.py # generate plot.png
@@ -144,6 +143,56 @@ pipelines:
144143
- cml comment create report.md
145144
```
146145
146+
</tab>
147+
<tab title="Bitbucket">
148+
149+
Bitbucket does not support GPUs natively
150+
([cml#1015](https://github.com/iterative/cml/issues/1015),
151+
[BCLOUD-21459](https://jira.atlassian.com/browse/BCLOUD-21459)). A work-around
152+
is to directly use
153+
[TPI](https://github.com/iterative/terraform-provider-iterative) (the library
154+
which CML `runner` uses internally). TPI includes a CLI-friendly helper called
155+
LEO (launch, execute, orchestrate), used below:
156+
157+
```yaml
158+
image: iterativeai/cml:0-dvc2-base1
159+
pipelines:
160+
default:
161+
- step:
162+
name: Launch Runner and Train
163+
script:
164+
# Create training script
165+
- |
166+
cat <<EOF > leo-script.sh
167+
#!/bin/bash
168+
apt-get update -q && apt-get install -yq python3.9
169+
pip3 install -r requirements.txt
170+
python train.py # generate plot.png
171+
EOF
172+
# Launch runner
173+
- |
174+
LEO_OPTIONS="--cloud=aws --region=us-west"
175+
leo_id=$(leo create $LEO_OPTIONS \
176+
--image=nvidia
177+
--machine=p2.xlarge \
178+
--disk-size=64 \
179+
--workdir=. \
180+
--output=. \
181+
--environment AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" \
182+
--environment AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \
183+
--script="$(cat ./leo-script.sh)"
184+
)
185+
# Wait for cloud training to finish
186+
leo read $LEO_OPTIONS --follow "$leo_id"
187+
sleep 45 # TODO: explain
188+
# Download cloud training results & clean up cloud resources
189+
leo delete $LEO_OPTIONS --workdir=. --output=. "$leo_id"
190+
# Create CML report
191+
- cat metrics.txt >> report.md
192+
- echo '![](./plot.png "Confusion Matrix")' >> report.md
193+
- cml comment create report.md
194+
```
195+
147196
</tab>
148197
</toggle>
149198

‎src/components/pages/Home/UseCasesSection/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,8 @@ const UseCasesSection: React.ForwardRefRenderFunction<HTMLElement> = () => (
673673
bitbucket={(
674674
<Collapser>
675675
<Code filename="bitbucket-pipelines.yml" repo="https://bitbucket.org/iterative-ai/cml-cloud-case">
676+
<div><span># Use LEO instead of CML to force GPU support on Bitbucket</span></div>
677+
<div><span># (<a href="/doc/ref/runner#bitbucket">https://cml.dev/doc/ref/runner#bitbucket</a>)</span></div>
676678
<div><span>image: iterativeai/cml:0-dvc2-base1</span></div>
677679
<div><span>pipelines:</span></div>
678680
<div> <span>default:</span></div>
@@ -705,7 +707,7 @@ const UseCasesSection: React.ForwardRefRenderFunction<HTMLElement> = () => (
705707
<div> <span>--script=&quot;$(cat ./leo-script.sh)&quot;</span></div>
706708
<div> <span>)</span></div>
707709
<div> <span>leo read $LEO_OPTIONS --follow &quot;$leo_id&quot;</span></div>
708-
<div> <span>sleep 45 # TODO: replace this hack with a proper wait loop</span></div>
710+
<div> <span>sleep 45 # TODO: explain</span></div>
709711
<div> <span>leo delete $LEO_OPTIONS --workdir=&quot;.&quot; --output=&quot;.&quot; \</span></div>
710712
<div> <span>&quot;$leo_id&quot;</span></div>
711713
</Tooltip>

0 commit comments

Comments
 (0)
This repository has been archived.