digitalbrain79 / pyyolo

Simple python wrapper for YOLO.
126 stars 65 forks source link

Multiprocessing and Multithreading using OpenMP #26

Open abhigoku10 opened 6 years ago

abhigoku10 commented 6 years ago

@thomaspark-pkj @jasrk11 @oulutan @rayhou0710 hii
when i run pyyolo it only uses single core processor in CPU , to enable the multicore usage in CPU , enabling of openmp option is not include .Can i manually add this? if i add what are the steps should i see in prior . I did not face this issue in darknet using c which had openMP enabled in make file

gf0507033 commented 6 years ago

Fast hack for openmp:

On ubuntu 16.04 you should add additional flags:

stucksubstitute commented 6 years ago

I can't make with -fopenmp

nvcc fatal : Unknown option 'fopenmp'

I'm using Ubuntu 16.04, trying with and without GPU

lesreaper commented 6 years ago

I get the same on Ubuntu 16

jjae2124 commented 6 years ago

I ran into the same problem. Just add the -fopenmp flag to the gcc compiler and leave the COMMON section empty, like this:

CC=gcc -fopenmp
AR=ar
NVCC=nvcc 
OPTS=-Ofast
COMMON=
CFLAGS=-Wall -Wfatal-errors -Wno-unused-result -fPIC
CFLAGS+=-I./darknet/src -I./darknet/include

that worked for me

lesreaper commented 6 years ago

Works well. Thank you @jjae2124 !

tylertroy commented 4 years ago

Just leaving a note here that related to my version of this problem and my solution.

TL;DR After adding the compile flags as per @gf0507033 , you must ensure that you delete the local ./build directory created by python setup_gpu.py build and before rebuilding and reinstalling the pyolo module.

I installed the repo according to the instructions for GPU mode but I instead created it in my own virtual python environment. As such when following the instructions to sudo python setup_gpu.py install it installed it under my default system python with version 2.7 but I wanted to use my own env. So I reran the install but without sudo a la python setup_gpu.py install. This appeared to execute properly (no errors) and returned.

$ python setup_gpu.py install
running build
running build_ext

I then ran pyyolo again and got the pow error this time. After finding this issue here, I followed the instructions to add the compile flags. After recompiling and reinstalling with setup_gpu.py it still gave the same error. As it turns out, nothing was being rebuilt because when I first tried to run the install with sudo it created the build directory with root ownership so that when I attempted to rebuild it was doing nothing because the build was already there. After deleting ./build and rebuilding and reinstalling it worked. Just so you know it's working the return from python setup_gpu.py install should actually look more like.

running build
running build_ext
building 'pyyolo' extension
creating build
creating build/temp.linux-x86_64-3.7
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/tyler/git/pyyolo/venv/lib/python3.7/site-packages/numpy/core/include -I./darknet/include -I/home/tyler/git/pyyolo/venv/include -I/usr/include/python3.7m -c module.c -o build/temp.linux-x86_64-3.7/module.o
module.c: In function ‘PyInit_pyyolo’:
module.c:160:17: warning: ‘return’ with no value, in function returning non-void
  if (m == NULL) return;
                 ^~~~~~
module.c:155:16: note: declared here
 PyMODINIT_FUNC PyInit_pyyolo(void)
                ^~~~~~~~~~~~~
In file included from /home/tyler/git/pyyolo/venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:21:0,
                 from /home/tyler/git/pyyolo/venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from module.c:3:
At top level:
/home/tyler/git/pyyolo/venv/lib/python3.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1463:1: warning: ‘_import_array’ defined but not used [-Wunused-function]
 _import_array(void)
 ^~~~~~~~~~~~~
creating build/lib.linux-x86_64-3.7
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.7/module.o -L. -L/usr/local/cuda/lib64 -L/usr/local/ -lyolo -lcuda -lcudart -lcublas -lcurand -lcudnn -o build/lib.linux-x86_64-3.7/pyyolo.cpython-37m-x86_64-linux-gnu.so