Skip to content

Commit

Permalink
TensorFlow release
Browse files Browse the repository at this point in the history
  • Loading branch information
JHogenboom committed Sep 4, 2024
1 parent cc0fe6f commit cb2bef6
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 45 deletions.
2 changes: 1 addition & 1 deletion algorithm_store.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
{
"name": "partial",
"description": "Retrieves GPU accessibility details for TensorFlow and PyTorch.",
"description": "Retrieves GPU accessibility details for TensorFlow.",
"type": "federated",
"databases": [],
"arguments": []
Expand Down
7 changes: 1 addition & 6 deletions docs/v6-gpu-accessibility/Implementation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,9 @@ node.

``partial``
~~~~~~~~~~~
The partial function retrieves GPU accessibility details for TensorFlow and PyTorch through the respective helper functions.
The partial function retrieves GPU accessibility details for TensorFlow through the helper function.

``get_tensorflow_gpu_details``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This function checks if TensorFlow is accessible on the GPU.
If a GPU is available it returns the GPU device name(s), memory, cores, and compute capability.

``get_pytorch_gpu_details``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This function checks if PyTorch is accessible on the GPU.
If a GPU is available it returns the GPU device name(s), memory, cores, and compute capability.
12 changes: 0 additions & 12 deletions docs/v6-gpu-accessibility/Validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ The following steps can be taken to verify the GPU accessibility:
.. code-block:: python
import tensorflow as tf
import torch
gpus = tf.config.list_physical_devices('GPU')
if not gpus:
Expand All @@ -18,14 +17,3 @@ The following steps can be taken to verify the GPU accessibility:
"cores": [tf.config.experimental.get_device_details(gpu)['core_count'] for gpu in gpus],
"compute capability": [tf.config.experimental.get_device_details(gpu)['compute_capability'] for gpu in gpus]
})
if not torch.cuda.is_available():
print('No GPUs available for PyTorch')
else:
print({
"number of GPUs": torch.cuda.device_count(),
"memory": f'{[torch.cuda.get_device_properties(i).total_memory for i in range(torch.cuda.device_count())]} bytes',
"cores": [torch.cuda.get_device_properties(i).multi_processor_count for i in range(torch.cuda.device_count())],
"compute capability": [torch.cuda.get_device_properties(i).major for i in range(torch.cuda.device_count())]
})
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
vantage6-algorithm-tools
pandas
tensorflow
torch
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
install_requires=[
'vantage6-algorithm-tools',
'pandas',
'tensorflow',
'torch'
'tensorflow'
]
)
26 changes: 3 additions & 23 deletions v6-gpu-accessibility/partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
or directly to the user (if they requested partial results).
"""
import tensorflow as tf
import torch

from typing import Any

Expand All @@ -19,20 +18,19 @@
@algorithm_client
def partial(client: AlgorithmClient) -> Any:
"""
Retrieves GPU accessibility details for TensorFlow and PyTorch.
Retrieves GPU accessibility details for TensorFlow.
Args:
client (AlgorithmClient): The algorithm client instance.
Returns:
dict: A dictionary containing the organisation ID and GPU accessibility details for TensorFlow and PyTorch.
dict: A dictionary containing the organisation ID and GPU accessibility details for TensorFlow.
"""
info("Retrieving details of any GPUs available to the algorithm's Docker container")
return {
'organisation_id': client.organization_id,
'gpu_accessibility': {
"Tensorflow": get_tensorflow_gpu_details(),
"PyTorch": get_pytorch_gpu_details()
"Tensorflow": get_tensorflow_gpu_details()
}
}

Expand All @@ -54,21 +52,3 @@ def get_tensorflow_gpu_details() -> dict or str:
"cores": [tf.config.experimental.get_device_details(gpu)['core_count'] for gpu in gpus],
"compute capability": [tf.config.experimental.get_device_details(gpu)['compute_capability'] for gpu in gpus]
}


def get_pytorch_gpu_details() -> dict or str:
"""
Retrieves details about available PyTorch GPUs.
Returns:
dict or str: A dictionary containing the number of GPUs, their names, memory, cores,
and compute capability if GPUs are available. Otherwise, returns 'No GPUs available'.
"""
if not torch.cuda.is_available():
return 'No GPUs available'
return {
"number of GPUs": torch.cuda.device_count(),
"memory": f"{[(torch.cuda.get_device_properties(i).total_memory/ (1024 * 1024)) for i in range(torch.cuda.device_count())]} MB",
"cores": [torch.cuda.get_device_properties(i).multi_processor_count for i in range(torch.cuda.device_count())],
"compute capability": [torch.cuda.get_device_properties(i).major for i in range(torch.cuda.device_count())]
}

0 comments on commit cb2bef6

Please sign in to comment.