Skip to content

Commit

Permalink
fix gpu loading
Browse files Browse the repository at this point in the history
  • Loading branch information
SippieCup committed Apr 18, 2020
1 parent 6a8e87e commit 8ddf155
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions selfdrive/modeld/runners/keras_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def read(sz):
def write(d):
os.write(1, d.tobytes())

def run_loop(m,name):
def run_loop(m):
isize = m.inputs[0].shape[1]
osize = m.outputs[0].shape[1]
print("ready to run keras model %d -> %d" % (isize, osize), file=sys.stderr)
Expand All @@ -42,9 +42,9 @@ def run_loop(m,name):
if len(gpus) > 0:
if os.path.splitext(os.path.basename(sys.argv[1]))[0]== "supercombo":
tf.config.experimental.set_virtual_device_configuration(gpus[0], [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=2548)])
with open(f"{os.path.splitext(sys.argv[1])}.model.keras", "r") as json_file:
with open(f"{os.path.splitext(sys.argv[1])[0]}.model.keras", "r") as json_file:
m = model_from_json(json_file.read())
m.load_weights(f"{os.path.splitext(sys.argv[1])}.weights.keras")
m.load_weights(f"{os.path.splitext(sys.argv[1])[0]}.weights.keras")
else:
tf.config.experimental.set_virtual_device_configuration(gpus[0], [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=256)])
m = load_model(sys.argv[1], compile=False)
Expand All @@ -62,5 +62,5 @@ def run_loop(m,name):
tii.append(tr)
no = keras.layers.Concatenate()(m(tii))
m = Model(inputs=ri, outputs=[no])
run_loop(m,name)
run_loop(m)

0 comments on commit 8ddf155

Please sign in to comment.