Skip to content
Snippets Groups Projects
Commit f79ac459 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Merge branch 'gpu_sample' into 'master'

Gpu sample

See merge request !20
parents 6c79c21f ffbd06c1
Branches
No related tags found
1 merge request!20GPU sample
{
"type": "sequential",
"groups": [
{
"outputs": {
"scores": {
"type": "{{ user.username }}/probe_scores/1"
}
},
"inputs": {
"client_id": {
"type": "{{ system_user.username }}/uint64/1"
}
},
"name": "main"
}
],
"parameters": {
"offset": {
"type": "uint32",
"default": 10,
"description": "Offset"
}
},
"schema_version": 2,
"api_version": 2,
"description": "",
"splittable": false,
"language": "python"
}
###############################################################################
# #
# Copyright (c) 2019 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# This file is part of the beat.examples module of the BEAT platform. #
# #
# Commercial License Usage #
# Licensees holding valid commercial BEAT licenses may use this file in #
# accordance with the terms contained in a written agreement between you #
# and Idiap. For further information contact tto@idiap.ch #
# #
# Alternatively, this file may be used under the terms of the GNU Affero #
# Public License version 3 as published by the Free Software and appearing #
# in the file LICENSE.AGPL included in the packaging of this file. #
# The BEAT platform is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. #
# #
# You should have received a copy of the GNU Affero Public License along #
# with the BEAT platform. If not, see http://www.gnu.org/licenses/. #
# #
###############################################################################
import numpy
import torch
class Algorithm:
def __init__(self):
self.offset = 1
def setup(self, parameters):
self.offset = numpy.asscalar(parameters['offset'])
return torch.cuda.is_available()
def process(self, inputs, data_loaders, outputs):
client_id = inputs['client_id'].data.value
x = torch.FloatTensor(1, 1).fill_(numpy.asscalar(client_id)).cuda()
y = torch.FloatTensor(1, 1).fill_(self.offset).cuda()
z = x + y
score = z.cpu().numpy().astype(numpy.int32)[0][0]
scores = [
{
'template_identity': client_id,
'score': score if client_id % 2 else -score
},
{
'template_identity': 0,
'score': -score if client_id % 2 else score
}
]
outputs['scores'].write({
'client_identity': client_id,
'scores': scores
})
return True
.. Copyright (c) 2019 Idiap Research Institute, http://www.idiap.ch/ ..
.. Contact: beat.support@idiap.ch ..
.. ..
.. This file is part of the beat.examples module of the BEAT platform. ..
.. ..
.. Commercial License Usage ..
.. Licensees holding valid commercial BEAT licenses may use this file in ..
.. accordance with the terms contained in a written agreement between you ..
.. and Idiap. For further information contact tto@idiap.ch ..
.. ..
.. Alternatively, this file may be used under the terms of the GNU Affero ..
.. Public License version 3 as published by the Free Software and appearing ..
.. in the file LICENSE.AGPL included in the packaging of this file. ..
.. The BEAT platform is distributed in the hope that it will be useful, but ..
.. WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ..
.. or FITNESS FOR A PARTICULAR PURPOSE. ..
.. ..
.. You should have received a copy of the GNU Affero Public License along ..
.. with the BEAT platform. If not, see http://www.gnu.org/licenses/. ..
Minimal algorithm validating GPU setup.
\ No newline at end of file
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
"number-of-components": { "number-of-components": {
"default": 5, "default": 5,
"type": "uint32", "type": "uint32",
"number-of-components": "the number of dimensions to retain after applying PCA" "description": "the number of dimensions to retain after applying PCA"
} }
} }
} }
{
"blocks": {
"block_1": {
"outputs": {
"scores": "scores"
},
"algorithm": "{{ user.username }}/gpu_test/1",
"inputs": {
"client_id": "input"
}
}
},
"globals": {
"queue": "{{ queue }}",
"{{ user.username }}/gpu_test/1": {
"offset": 10
},
"environment": {
"version": "0.0.1",
"name": "Pytorch 0.4.0"
}
},
"analyzers": {
"analyzer_1": {
"nb_slots": 1,
"algorithm": "{{ user.username }}/postperf_iso/1",
"inputs": {
"scores": "scores"
},
"queue": "{{ queue }}",
"environment": {
"version": "{{ environment.version }}",
"name": "{{ environment.name }}"
}
}
},
"datasets": {
"templates": {
"set": "templates",
"protocol": "idiap",
"database": "atnt/5"
}
}
}
\ No newline at end of file
{
"connections": [
{
"to": "analyzer_1.scores",
"from": "block_1.scores",
"channel": "templates"
},
{
"to": "block_1.input",
"from": "templates.file_id",
"channel": "templates"
}
],
"analyzers": [
{
"inputs": [
"scores"
],
"synchronized_channel": "templates",
"name": "analyzer_1"
}
],
"datasets": [
{
"outputs": [
"client_id",
"file_id",
"image",
"template_id"
],
"name": "templates"
}
],
"blocks": [
{
"inputs": [
"input"
],
"synchronized_channel": "templates",
"name": "block_1",
"outputs": [
"scores"
]
}
],
"representation": {
"connections": {
"templates.file_id/block_1.input": [
{
"col": 9,
"row": 6
},
{
"col": 10,
"row": 6
},
{
"col": 14,
"row": 6
},
{
"col": 15,
"row": 6
}
],
"block_1.scores/analyzer_1.scores": [
{
"col": 21,
"row": 6
},
{
"col": 22,
"row": 6
},
{
"col": 24,
"row": 6
},
{
"col": 25,
"row": 6
}
]
},
"blocks": {
"templates": {
"width": 5,
"height": 6,
"col": 4,
"row": 3
},
"block_1": {
"width": 6,
"height": 3,
"col": 15,
"row": 4
},
"analyzer_1": {
"width": 6,
"height": 3,
"col": 25,
"row": 4
}
},
"channel_colors": {
"templates": "#0000FF"
}
}
}
.. Copyright (c) 2019 Idiap Research Institute, http://www.idiap.ch/ ..
.. Contact: beat.support@idiap.ch ..
.. ..
.. This file is part of the beat.examples module of the BEAT platform. ..
.. ..
.. Commercial License Usage ..
.. Licensees holding valid commercial BEAT licenses may use this file in ..
.. accordance with the terms contained in a written agreement between you ..
.. and Idiap. For further information contact tto@idiap.ch ..
.. ..
.. Alternatively, this file may be used under the terms of the GNU Affero ..
.. Public License version 3 as published by the Free Software and appearing ..
.. in the file LICENSE.AGPL included in the packaging of this file. ..
.. The BEAT platform is distributed in the hope that it will be useful, but ..
.. WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ..
.. or FITNESS FOR A PARTICULAR PURPOSE. ..
.. ..
.. You should have received a copy of the GNU Affero Public License along ..
.. with the BEAT platform. If not, see http://www.gnu.org/licenses/. ..
Implements a simple pass through for validating GPU setup.
\ No newline at end of file
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
], ],
"parameters": { "parameters": {
"offset": { "offset": {
"default": "1", "default": 1,
"type": "int32" "type": "int32"
} }
}, },
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
], ],
"parameters": { "parameters": {
"offset": { "offset": {
"default": "1", "default": 1,
"type": "int32" "type": "int32"
} }
}, },
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
], ],
"parameters": { "parameters": {
"offset": { "offset": {
"default": "1", "default": 1,
"type": "int32" "type": "int32"
}, },
"sync": { "sync": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment