-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add single twist and frontend many updates
- Loading branch information
Showing
28 changed files
with
1,345 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
gh run list --json status,workflowName,databaseId --jq '.[] | select(.status=="in_progress")' | | ||
while read -r run; do | ||
id=$(echo "$run" | jq -r '.databaseId') | ||
workflow_name=$(echo "$run" | jq -r '.workflowName') | ||
|
||
echo "Canceling running workflow '$workflow_name' (#$id)" | ||
gh run cancel $id | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# File: example_twist.yml | ||
# Author: Ryoichi Ando ([email protected]) | ||
# License: Apache v2.0 | ||
|
||
name: twist.ipynb | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
runner: | ||
type: string | ||
required: true | ||
description: 'Runner Name' | ||
|
||
env: | ||
VAST_API_KEY: ${{ secrets.VAST_API_KEY }} | ||
EXAMPLE_NAME: twist | ||
HELPER_PATH: .github/workflows/vast/helper.sh | ||
|
||
jobs: | ||
run: | ||
runs-on: ${{ github.event.inputs.runner }} | ||
steps: | ||
|
||
- name: check out repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: print scene | ||
run: | | ||
echo "Scene: $EXAMPLE_NAME" >> $GITHUB_STEP_SUMMARY | ||
- name: prepare | ||
timeout-minutes: 30 | ||
run: bash $HELPER_PATH create $VAST_API_KEY | ||
|
||
- name: 1st run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 2nd run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 3rd run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 4th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 5th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 6th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 7th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 8th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 9th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 10th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: shutdown | ||
if: always() | ||
run: bash $HELPER_PATH delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ]; then | ||
echo "Error: Missing string parameter." | ||
echo "Usage: $0 <runner>" | ||
exit 1 | ||
fi | ||
|
||
runner="$1" | ||
|
||
WORKFLOW_PATTERN="example_*" | ||
WORKFLOW_FILES=$(ls $WORKFLOW_PATTERN*.yml 2>/dev/null) | ||
|
||
if [ -z "$WORKFLOW_FILES" ]; then | ||
echo "No workflow files found." | ||
exit 1 | ||
fi | ||
|
||
for WORKFLOW_FILE in $WORKFLOW_FILES; do | ||
echo "Triggering GitHub Action workflow: $WORKFLOW_FILE with runner=$runner" | ||
gh workflow run "$WORKFLOW_FILE" -f runner="$runner" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include <cuda_runtime.h> | ||
#include <stdio.h> | ||
|
||
__global__ void vectorAdd(const float *A, const float *B, float *C, int n) { | ||
int idx = blockIdx.x * blockDim.x + threadIdx.x; | ||
if (idx < n) { | ||
C[idx] = A[idx] + B[idx]; | ||
} | ||
} | ||
|
||
void checkCudaError(cudaError_t err, const char *msg) { | ||
if (err != cudaSuccess) { | ||
fprintf(stderr, "CUDA Error: %s: %s\n", msg, cudaGetErrorString(err)); | ||
exit(EXIT_FAILURE); | ||
} | ||
} | ||
|
||
int main() { | ||
const int N = 1024; // Vector size | ||
size_t size = N * sizeof(float); | ||
|
||
float *h_A = (float *)malloc(size); | ||
float *h_B = (float *)malloc(size); | ||
float *h_C = (float *)malloc(size); | ||
|
||
for (int i = 0; i < N; i++) { | ||
h_A[i] = i; | ||
h_B[i] = i * 2; | ||
} | ||
|
||
float *d_A, *d_B, *d_C; | ||
checkCudaError(cudaMalloc(&d_A, size), "cudaMalloc A"); | ||
checkCudaError(cudaMalloc(&d_B, size), "cudaMalloc B"); | ||
checkCudaError(cudaMalloc(&d_C, size), "cudaMalloc C"); | ||
|
||
checkCudaError(cudaMemcpy(d_A, h_A, size, cudaMemcpyHostToDevice), | ||
"cudaMemcpy A"); | ||
checkCudaError(cudaMemcpy(d_B, h_B, size, cudaMemcpyHostToDevice), | ||
"cudaMemcpy B"); | ||
|
||
int threadsPerBlock = 256; | ||
int blocksPerGrid = (N + threadsPerBlock - 1) / threadsPerBlock; | ||
vectorAdd<<<blocksPerGrid, threadsPerBlock>>>(d_A, d_B, d_C, N); | ||
|
||
checkCudaError(cudaGetLastError(), "Kernel launch"); | ||
checkCudaError(cudaDeviceSynchronize(), "Kernel synchronization"); | ||
|
||
checkCudaError(cudaMemcpy(h_C, d_C, size, cudaMemcpyDeviceToHost), | ||
"cudaMemcpy result"); | ||
|
||
bool success = true; | ||
for (int i = 0; i < N; i++) { | ||
if (h_C[i] != h_A[i] + h_B[i]) { | ||
printf("Verification failed at index %d: %f != %f + %f\n", i, | ||
h_C[i], h_A[i], h_B[i]); | ||
success = false; | ||
break; | ||
} | ||
} | ||
checkCudaError(cudaFree(d_A), "cudaFree A"); | ||
checkCudaError(cudaFree(d_B), "cudaFree B"); | ||
checkCudaError(cudaFree(d_C), "cudaFree C"); | ||
free(h_A); | ||
free(h_B); | ||
free(h_C); | ||
|
||
if (success) { | ||
printf("CUDA test passed successfully!\n"); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,15 @@ | |
# Author: Ryoichi Ando ([email protected]) | ||
# License: Apache v2.0 | ||
|
||
# CUDA tester file path | ||
CUDA_TESTER_PATH=$(pwd)/.github/workflows/vast/cuda-tester.cu | ||
|
||
# check if the CUDA tester file exists | ||
if [ ! -f "$CUDA_TESTER_PATH" ]; then | ||
echo "Error: CUDA tester file not found: $CUDA_TESTER_PATH" | ||
exit 1 | ||
fi | ||
|
||
# set working directory | ||
WORKDIR=/tmp/vast-ci | ||
|
||
|
@@ -186,6 +195,7 @@ while true; do | |
# Loop until SSH connection is successful | ||
retry_count=0 | ||
ssh_ready=false | ||
cuda_ready=false | ||
while true; do | ||
sleep $RETRY_INTERVAL | ||
echo "trying to establish SSH connection..." | ||
|
@@ -205,6 +215,20 @@ while true; do | |
fi | ||
done | ||
if [ "$ssh_ready" = true ]; then | ||
break | ||
scp_command="scp -i $WORKDIR/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5 -P $port $CUDA_TESTER_PATH root@${hostname}:/tmp/" | ||
echo "==== copy cuda-tester.cu ======" | ||
echo $scp_command | ||
eval $scp_command | ||
echo "==== compile cuda ======" | ||
eval $ssh_command "nvcc /tmp/cuda-tester.cu -o /tmp/cuda-tester" | ||
echo "==== run cuda ======" | ||
eval $ssh_command "/tmp/cuda-tester" | ||
if [ $? -eq 0 ]; then | ||
cuda_ready=true | ||
break | ||
else | ||
echo "CUDA test failed" | ||
$WORKDIR/delete-instance.sh | ||
fi | ||
fi | ||
done | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.