Skip to content

Commit

Permalink
fixed finally get q
Browse files Browse the repository at this point in the history
  • Loading branch information
williamFalcon committed Feb 15, 2018
1 parent eec817f commit c9ca14f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test_tube/argparse_hopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@


def optimize_parallel_gpu_cuda_private(args):
try:
trial_params, train_function = args[0], args[1]
trial_params, train_function = args[0], args[1]

# get set of gpu ids
gpu_id_set = g_gpu_id_q.get(block=True)
# get set of gpu ids
gpu_id_set = g_gpu_id_q.get(block=True)
try:
sleep(random.randint(0, 4))

# enable the proper gpus
Expand All @@ -27,9 +27,6 @@ def optimize_parallel_gpu_cuda_private(args):
# run training fx on the specific gpus
train_function(trial_params)

# when done, free up the gpus
g_gpu_id_q.put(gpu_id_set, block=True)

except Exception as e:
print('Caught exception in worker thread')

Expand All @@ -38,6 +35,10 @@ def optimize_parallel_gpu_cuda_private(args):
traceback.print_exc()
raise e

finally:
# when done, free up the gpus
g_gpu_id_q.put(gpu_id_set, block=True)

return True


Expand Down

0 comments on commit c9ca14f

Please sign in to comment.