diff --git a/.github/workflows/nvidia_workflow.yml b/.github/workflows/nvidia_workflow.yml index 9328ea4..8e9049f 100644 --- a/.github/workflows/nvidia_workflow.yml +++ b/.github/workflows/nvidia_workflow.yml @@ -10,6 +10,7 @@ on: description: 'Name of script (supports .py or .cu)' required: true type: string + jobs: train: runs-on: [gpumode-nvidia-arc] @@ -21,38 +22,43 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.10' - + - name: Install uv uses: astral-sh/setup-uv@v3 with: version: "latest" - + - name: Setup Python environment run: | - uv venv .venv - echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV - echo "$PWD/.venv/bin" >> $GITHUB_PATH - + if [[ "${{ github.event.inputs.filename }}" != *.cu ]]; then + uv venv .venv + echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV + echo "$PWD/.venv/bin" >> $GITHUB_PATH + fi + - name: Create script shell: python run: | + import re + content = '''${{ github.event.inputs.script_content }}''' + # Fix escaped newlines in string literals + content = re.sub(r'\\n"', '\\\\n"', content) with open('${{ github.event.inputs.filename }}', 'w') as f: - f.write('''${{ github.event.inputs.script_content }}''') - - - name: Install dependencies and setup NVCC - run: | + f.write(content) + + - name: Install dependencies + run: | # Check for PyTorch if grep -rE "(import torch|from torch)" "${{ github.event.inputs.filename }}"; then echo "PyTorch detected, installing torch" uv pip install numpy torch fi - # Check for Triton if grep -rE "(import triton|from triton)" "${{ github.event.inputs.filename }}"; then echo "Triton detected, installing triton" uv pip install triton fi - + - name: Run script with profiler run: | if [[ "${{ github.event.inputs.filename }}" == *.cu ]]; then @@ -63,7 +69,7 @@ jobs: # Run Python file python "${{ github.event.inputs.filename }}" > training.log 2>&1 fi - + - name: Upload training artifacts uses: actions/upload-artifact@v4 if: always() @@ -71,8 +77,8 @@ jobs: name: training-artifacts path: | training.log - # profile_results.csv ${{ github.event.inputs.filename }} cuda_program* - env: - CUDA_VISIBLE_DEVICES: 0 # Make sure only one GPU is used for testing \ No newline at end of file + + env: + CUDA_VISIBLE_DEVICES: 0 \ No newline at end of file