choyingw / SynergyNet

3DV 2021: Synergy between 3DMM and 3D Landmarks for Accurate 3D Facial Geometry
MIT License
377 stars 57 forks source link

Problem compiling FaceBoxes #29

Closed pepeballesterostel closed 2 weeks ago

pepeballesterostel commented 1 year ago

After trying a couple of times, I find impossible to correctly compile the file _./build_cpunms.sh. The error is:

cl : Command line error D8021 : **invalid numeric argument '/Wno-cpp'**
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2

I am not sure if this could be related to the operating system. I am running the code in Visual Studio Code on Windows 11.

Looking after the error I found this. So I changed in build.py inside FaceBoxes/utils the line of code 47: from extra_compile_args=["-Wno-cpp", "-Wno-unused-function"] to extra_compile_args={'gcc': ['/Qstd=c99']} After running this, I get the following warnings:

cl : Command line warning D9024 : unrecognized source file type 'gcc', object file assumed
cl : Command line warning D9027 : source file 'gcc' ignored

From where I assume that is basically not compiling the extra modules, but ignoring it. So, it does not show and error, but as expected, the code does not work. The error raises in _FaceBoxes\utils\nmswrapper.py :

  File "nms\cpu_nms.pyx", line 25, in nms.cpu_nms.cpu_nms
ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'

I also tried commenting line 47 - in build.py inside FaceBoxes/utils - and uncommenting line 46, which raises the same error.

Any ideas how to solve this? Many thanks.

RichestYoo commented 1 year ago

Just the same for me

pepeballesterostel commented 1 year ago

@RichestYoo I am pretty sure I have solved the problem adding this line of code: os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE" Let me know

RichestYoo commented 1 year ago

@pepeballesterostel Where am I supposed to put that line in?

I put that in FaceBoxes/utils/build.py like the following failed: ext_modules = [ Extension( "nms.cpu_nms", ["nms/cpu_nms.pyx"], extra_compile_args=["-Wno-cpp", "-Wno-unused-function"], include_dirs=[numpy_include], os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE" ) ]

And "TRUE", instead of True seems to say that it's not a python source.

pepeballesterostel commented 1 year ago

@RichestYoo Put it in the main script that you are running, for example singleImage.py. I added it after the imports. The command basically tells python that is ok to have multiple copies of the library MKL loaded into memory, which seems to be the initial compiling error.

RichestYoo commented 1 year ago

@pepeballesterostel Thank you for your help, but it didn't work out for me. After first failure, I put that in the environment variable as "os.environ" is bringing/setting PC's environment variable, and tried again, but same error message came up.

pepeballesterostel commented 1 year ago

@RichestYoo Try changing your code from build.py to this code: ext_modules = [ Extension( "nms.cpu_nms", ["nms/cpu_nms.pyx"],

extra_compile_args={'gcc': ["-Wno-cpp", "-Wno-unused-function"]},

    extra_compile_args=['std=c99'],
    include_dirs=[numpy_include]
)

] Does this work for you?

RichestYoo commented 1 year ago

@pepeballesterostel With that, I passed the build failure you wrote at the beginning but now I'm at this "int_t" vs. 'long long' stuff...

pepeballesterostel commented 1 year ago

@RichestYoo Those changes worked for me. I suggest you try to re-do the whole process installing everything into a separate conda environment.

RichestYoo commented 1 year ago

@pepeballesterostel Sure. Thank you for your sincere helps.

HeChengHui commented 1 year ago

@RichestYoo did you managed to get it working?

i have added extra_compile_args=['std=c99'], to FaceBoxes build.py and os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE" to singleImage.py butstuck at 'int_t' but got 'long long' problem.

RichestYoo commented 1 year ago

Thank you for your help, but I'm transferred to another job and is not working on this any more.