diff --git a/examples/detector.py b/examples/detector.py index aa565d61..5b639a3a 100644 --- a/examples/detector.py +++ b/examples/detector.py @@ -8,6 +8,7 @@ sys.path.append(os.path.join(os.getcwd(),'python/')) import darknet as dn +dn.set_gpu(0) net = dn.load_net("cfg/tiny-yolo.cfg", "tiny-yolo.weights", 0) meta = dn.load_meta("cfg/coco.data") r = dn.detect(net, meta, "data/dog.jpg") diff --git a/python/darknet.py b/python/darknet.py index d6dfd31f..f9aab1ee 100644 --- a/python/darknet.py +++ b/python/darknet.py @@ -44,6 +44,9 @@ predict = lib.network_predict predict.argtypes = [c_void_p, POINTER(c_float)] predict.restype = POINTER(c_float) +set_gpu = lib.cuda_set_device +set_gpu.argtypes = [c_int] + make_image = lib.make_image make_image.argtypes = [c_int, c_int, c_int] make_image.restype = IMAGE diff --git a/src/cuda.c b/src/cuda.c index b5c0c329..48aba6e4 100644 --- a/src/cuda.c +++ b/src/cuda.c @@ -172,5 +172,7 @@ float cuda_mag_array(float *x_gpu, size_t n) free(temp); return m; } +#else +void cuda_set_device(int n){} #endif