libtorch-mac-m1 icon indicating copy to clipboard operation
libtorch-mac-m1 copied to clipboard

OpenMP build relies on homebrew?

Open zap150 opened this issue 2 years ago • 0 comments

I believe there is a problem with including the libomp from homebrew. While you seem to perform

install_name_tool -change /opt/homebrew/opt/libomp/lib/libomp.dylib @rpath/libomp.dylib libtorch/lib/libtorch_cpu.dylib

in your workflow, I still see

otool -L lib/libtorch_cpu.dylib 
lib/libtorch_cpu.dylib:
	@rpath/libtorch_cpu.dylib (compatibility version 0.0.0, current version 0.0.0)
        ...
	/opt/homebrew/opt/libomp/lib/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)

Moreover, I think you should also do something like

install_name_tool -id @rpath/libomp.dylib libtorch/lib/libomp.dylib

to fix

otool -L lib/libomp.dylib
lib/libomp.dylib:
	/opt/homebrew/opt/libomp/lib/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)

This can cause troubles both when not using homebrew on your system at all, or when trying to compile something against a different package manager while having hombrew installed. (I do not have omp installed from homebrew at the mooment, so the path does not exist.)

zap150 avatar Nov 22 '23 11:11 zap150