api-samples/ops-agent/multi_tasks_per_node_w_gpu.yaml (34 lines of code) (raw):
taskGroups:
- taskSpec:
runnables:
- script:
text: |
# Check if Ops Agent is already installed
if ! dpkg -l | grep google-cloud-ops-agent; then
# Acquire a lock before proceeding
if mkdir /tmp/ops_agent_installation_lock; then
# Ops Agent is not installed, run the installation script
curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh
sudo bash add-google-cloud-ops-agent-repo.sh --also-install
# Release the lock
rmdir /tmp/ops_agent_installation_lock
else
# Another process is already installing, skip the installation
echo "Another process is already installing Ops Agent. Skipping installation."
fi
else
# Ops Agent is already installed, skip the installation
echo "Ops Agent is already installed. Skipping installation."
fi
- script:
text: "${FOLLOWING_SCRIPT}"
taskCount: "${TASK_COUNT}"
parallelism: "${PARALLELISM}"
taskCountPerNode: "${TASK_COUNT_PER_NODE}"
allocationPolicy:
instances:
- installGpuDrivers: true
policy:
machineType: "n1-standard-1"
accelerators:
- type: "${GPU_TYPE}"
count: 1
location:
allowedLocations:
- "${ALLOWED_LOCATIONS}"
logsPolicy:
destination: "CLOUD_LOGGING"