Error when trying to run test python test/dynamo/test_backends.py
#include <omp.h>
^~~~~~~
1 error generated.
#include <omp.h>
^~~~~~~
1 error generated.
You can suppress this exception and fall back to eager by setting:
import torch._dynamo
torch._dynamo.config.suppress_errors = True
I have LDFLAGS=“-L/opt/homebrew/Cellar/llvm/16.0.6/lib” CPPFLAGS=”-I/opt/homebrew/Cellar/llvm/16.0.6/lib/clang/16/include” as variables in the setup.py But these do not seem to make it into the dynamo compile => so the header is not resolved, because it does not see /opt/homebrew/Cellar/llvm/16.0.6/lib/clang/16/include . I am not sure how to get these llvm folders to be seen by the dynamo compile. It says that the compile it is trying to so is as follows - so I can see if does not have the llvm include folder.
The issue appears to be that I had installed xcode. The trick seems to be be to try to force the real Clang to be picked up over the apple supplied one, that does not play well with omp.
I ended up creating a batch file that sets the compiler environment variables to point to the brew llvm. So I run this prior to running the test involving the compiler. This forces the brew installed llvm to be used. The bash script I use is llvmEnv.sh. Of course you need to run it something like . ../tools/llvmEnv.sh so the current environment is updated.
I am now seeing library not found for -lomp which seems better but not there yet /opt/homebrew/opt/llvm/bin/clang++ /var/folders/wv/pmg4pqgs0kxb2471qr3bplzh0000gn/T/torchinductor_davidradley/ww/cwwa7rwekb5fdmzhngrduq3mfsuinbo5qqldlgof2pzwu7kb2l3c.cpp -shared -fPIC -Wall -std=c++17 -Wno-unused-variable -I/Users/davidradley/pytorch/torch/include -I/Users/davidradley/pytorch/torch/include/torch/csrc/api/include -I/Users/davidradley/pytorch/torch/include/TH -I/Users/davidradley/pytorch/torch/include/THC -I/Users/davidradley/miniconda3/include/python3.10 -I/Users/davidradley/miniconda3/include -L/Users/davidradley/miniconda3/lib -lomp -O3 -ffast-math -fno-finite-math-only -Xclang -fopenmp -D C10_USING_CUSTOM_GENERATED_MACROS -o /var/folders/wv/pmg4pqgs0kxb2471qr3bplzh0000gn/T/torchinductor_davidradley/ww/cwwa7rwekb5fdmzhngrduq3mfsuinbo5qqldlgof2pzwu7kb2l3c.so
if I remove the -lomp it compiles. I just need to find out who is adding the -lomp
the option omp is added in the codecache code - but is not recognised on my machine.
if sys.platform == "darwin":
# GNU OpenMP generally is not available on MacOS
# There is either Intel OpenMP(for x86) or LLVM OpenMP (for both x86 and arm64)
libs = ["omp"]
if os.getenv("CONDA_PREFIX") is not None:
# On MacOS OpenMP is not available via the system install
# But on conda can be provided using https://anaconda.org/anaconda/llvm-openmp
conda_lib_path = os.path.join(os.getenv("CONDA_PREFIX"), "lib")
ipaths.append(os.path.join(os.getenv("CONDA_PREFIX"), "include"))
lpaths.append(conda_lib_path)
# Prefer Intel OpenMP on x86 machine
if os.uname().machine == "x86_64" and os.path.exists(
os.path.join(conda_lib_path, "libiomp5.dylib")
):
libs = ["iomp5"]
else:
libs = ["omp"] if config.is_fbcode() else ["gomp"]