Skip to content

Commit

Permalink
[CLEANUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Oct 9, 2024
1 parent 02947f6 commit 8c304c9
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,33 @@ pip3 install -U clusterops
The following example demonstrates how to use ClusterOps to run tasks on specific CPUs and GPUs.

```python
from clusterops import execute_with_cpu_cores, execute_on_gpu, retry_with_backoff

# Sample function to execute
from clusterops import (
list_available_cpus,
execute_with_cpu_cores,
list_available_gpus,
execute_on_gpu,
execute_on_multiple_gpus,
)

# Example function to run
def sample_task(n: int) -> int:
return n * n

# Run the task on 4 CPU cores
result_cpu = execute_with_cpu_cores(4, sample_task, 10)
print(f"Result on CPU cores: {result_cpu}")

# Run the task on the best available GPU with retries
result_gpu = retry_with_backoff(execute_on_gpu, None, sample_task, 10)
print(f"Result on GPU: {result_gpu}")
# List CPUs and execute on CPU 0
cpus = list_available_cpus()
execute_on_cpu(0, sample_task, 10)

# List CPUs and execute using 4 CPU cores
execute_with_cpu_cores(4, sample_task, 10)

# List GPUs and execute on GPU 0
gpus = list_available_gpus()
execute_on_gpu(0, sample_task, 10)

# Execute across multiple GPUs
execute_on_multiple_gpus([0, 1], sample_task, 10)

```

---
Expand Down

0 comments on commit 8c304c9

Please sign in to comment.