Args: val: an integer, the index of the GPU or -1 to disable GPU. Returns: a context where ``CUDA_VISIBLE_DEVICES=val``.
(val)
| 13 | |
| 14 | |
| 15 | def change_gpu(val): |
| 16 | """ |
| 17 | Args: |
| 18 | val: an integer, the index of the GPU or -1 to disable GPU. |
| 19 | |
| 20 | Returns: |
| 21 | a context where ``CUDA_VISIBLE_DEVICES=val``. |
| 22 | """ |
| 23 | val = str(val) |
| 24 | if val == '-1': |
| 25 | val = '' |
| 26 | return change_env('CUDA_VISIBLE_DEVICES', val) |
| 27 | |
| 28 | |
| 29 | def get_num_gpu(): |
no test coverage detected