-
Notifications
You must be signed in to change notification settings - Fork 3
60 lines (53 loc) · 1.66 KB
/
train_workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Training Workflow
on:
workflow_dispatch:
inputs:
script_content:
description: 'Content of training script (Python or CUDA)'
required: true
type: string
script_type:
description: 'Script type (py or cu)'
required: true
type: choice
options:
- py
- cu
jobs:
train:
runs-on: ubuntu-latest
steps:
- name: Set up environment variables
run: |
echo "SCRIPT_FILE=train.${{ inputs.script_type }}" >> $GITHUB_ENV
echo "OUTPUT_FILE=training.log" >> $GITHUB_ENV
- name: Install Python dependencies
if: inputs.script_type == 'py'
run: |
pip install numpy
# Add other Python dependencies as needed
- name: Install CUDA dependencies
if: inputs.script_type == 'cu'
run: |
sudo apt-get update
sudo apt-get install -y nvidia-cuda-toolkit
nvcc --version
- name: Create training script
run: |
echo "${{ inputs.script_content }}" > ${{ env.SCRIPT_FILE }}
cat ${{ env.SCRIPT_FILE }} # Debug: print the content
- name: Compile and run CUDA script
if: inputs.script_type == 'cu'
run: |
nvcc ${{ env.SCRIPT_FILE }} -o train_cuda
./train_cuda > ${{ env.OUTPUT_FILE }} 2>&1
- name: Run Python script
if: inputs.script_type == 'py'
run: |
python ${{ env.SCRIPT_FILE }} > ${{ env.OUTPUT_FILE }} 2>&1
- name: Upload logs
uses: actions/upload-artifact@v3
if: always()
with:
name: training-logs
path: ${{ env.OUTPUT_FILE }}