Skip to content

Commit

Permalink
auto fp16 if device supports it
Browse files Browse the repository at this point in the history
  • Loading branch information
iiSeymour committed Sep 1, 2020
1 parent 67fb27f commit 82907bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bonito/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from bonito.training import ChunkDataSet
from bonito.util import accuracy, poa, decode_ref
from bonito.util import init, load_data, load_model
from bonito.util import init, load_data, load_model, half_supported

from torch.utils.data import DataLoader

Expand Down Expand Up @@ -80,7 +80,7 @@ def argparser():
parser.add_argument("model_directory")
parser.add_argument("--directory", default=None)
parser.add_argument("--device", default="cuda")
parser.add_argument("--half", action="store_true", default=False)
parser.add_argument("--half", action="store_true", default=half_supported())
parser.add_argument("--seed", default=9, type=int)
parser.add_argument("--weights", default="0", type=str)
parser.add_argument("--chunks", default=500, type=int)
Expand Down
8 changes: 8 additions & 0 deletions bonito/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import parasail
import numpy as np
from scipy.signal import find_peaks
from torch.cuda import get_device_capability
from ont_fast5_api.fast5_interface import get_fast5_file

try:
Expand Down Expand Up @@ -81,6 +82,13 @@ def init(seed, device):
assert(torch.cuda.is_available())


def half_supported():
"""
Returns whether FP16 is support on the GPU
"""
return get_device_capability()[0] >= 7


def phred(prob, scale=1.0, bias=0.0):
"""
Converts `prob` into a ascii encoded phred quality score between 0 and 40.
Expand Down

0 comments on commit 82907bd

Please sign in to comment.