pair_nequip
pair_nequip copied to clipboard
error: use of undeclared identifier 'assert' when compiling LAMMPS
Hi there,
I am on Mac OS 10.15.6. When I was trying to compile LAMMPS with NequIP patched with the following command:
cmake -D BUILD_LIB=yes -D BUILD_SHARED_LIBS=yes -D BUILD_MPI=ON -D BUILD_OMP=yes -D PKG_MPIIO=ON -D LAMMPS_EXCEPTIONS=yes -D PKG_MANYBODY=ON -D PKG_MISC=ON -D PKG_MISC=ON -D PKG_EXTRA-COMPUTE=ON -D PKG_EXTRA-DUMP=ON -D PKG_EXTRA-FIX=ON -D PKG_EXTRA-PAIR=ON -DCMAKE_PREFIX_PATH=
python -c 'import torch;print(torch.utils.cmake_prefix_path)' -DMKL_INCLUDE_DIR="$CONDA_PREFIX/include" ../cmake
I encountered the following error when compiling force.cpp:
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/src/force.cpp:21:
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/m/styles/style_pair.h:71:
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/src/pair_nequip.h:25:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/ATen.h:9:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Context.h:4:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Tensor.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/core/TensorBody.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Operators.h:13:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/Scalar.h:11:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/ScalarType.h:6:
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/Optional.h:717:12: error: use of undeclared identifier 'assert'
return TR2_OPTIONAL_ASSERTED_EXPRESSION(initialized(), dataptr());
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/Optional.h:81:29: note: expanded from macro 'TR2_OPTIONAL_ASSERTED_EXPRESSION'
((CHECK) ? (EXPR) : ([] { assert(!#CHECK); }(), (EXPR)))
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/Optional.h:726:12: error: use of undeclared identifier 'assert'
return TR2_OPTIONAL_ASSERTED_EXPRESSION(initialized(), contained_val());
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/Optional.h:81:29: note: expanded from macro 'TR2_OPTIONAL_ASSERTED_EXPRESSION'
((CHECK) ? (EXPR) : ([] { assert(!#CHECK); }(), (EXPR)))
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/Optional.h:880:12: error: use of undeclared identifier 'assert'
return TR2_OPTIONAL_ASSERTED_EXPRESSION(ref, ref);
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/Optional.h:81:29: note: expanded from macro 'TR2_OPTIONAL_ASSERTED_EXPRESSION'
((CHECK) ? (EXPR) : ([] { assert(!#CHECK); }(), (EXPR)))
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/Optional.h:884:12: error: use of undeclared identifier 'assert'
return TR2_OPTIONAL_ASSERTED_EXPRESSION(ref, *ref);
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/Optional.h:81:29: note: expanded from macro 'TR2_OPTIONAL_ASSERTED_EXPRESSION'
((CHECK) ? (EXPR) : ([] { assert(!#CHECK); }(), (EXPR)))
^
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/src/force.cpp:21:
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/m/styles/style_pair.h:71:
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/src/pair_nequip.h:25:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/ATen.h:9:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Context.h:4:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Tensor.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/core/TensorBody.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Operators.h:14:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/TensorOptions.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/Backend.h:5:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/DispatchKeySet.h:6:
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:239:3: error: use of undeclared identifier 'assert'
assert(N <= Bits && "Invalid bit index");
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:406:3: error: use of undeclared identifier 'assert'
assert(N > 0 && N <= 64 && "integer width out of range");
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:423:3: error: use of undeclared identifier 'assert'
assert(N > 0 && N <= 64 && "integer width out of range");
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:434:3: error: use of undeclared identifier 'assert'
assert(N > 0 && N <= 64 && "integer width out of range");
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:661:3: error: use of undeclared identifier 'assert'
assert(
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:665:3: error: use of undeclared identifier 'assert'
assert((uintptr_t)Addr + Alignment - 1 >= (uintptr_t)Addr);
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:725:3: error: use of undeclared identifier 'assert'
assert(Align != 0u && "Align can't be 0.");
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:759:3: error: use of undeclared identifier 'assert'
assert(Align != 0u && "Align can't be 0.");
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:783:3: error: use of undeclared identifier 'assert'
assert(B > 0 && "Bit width can't be 0.");
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:784:3: error: use of undeclared identifier 'assert'
assert(B <= 32 && "Bit width out of range.");
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:800:3: error: use of undeclared identifier 'assert'
assert(B > 0 && "Bit width can't be 0.");
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/llvmMathExtras.h:801:3: error: use of undeclared identifier 'assert'
assert(B <= 64 && "Bit width out of range.");
^
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/src/force.cpp:21:
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/m/styles/style_pair.h:71:
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/src/pair_nequip.h:25:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/ATen.h:9:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Context.h:4:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Tensor.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/core/TensorBody.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Operators.h:13:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/Scalar.h:11:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/ScalarType.h:6:
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/Optional.h:721:5: error: use of undeclared identifier 'assert'
assert(initialized());
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/ScalarTypeToTypeMeta.h:34:19: note: in instantiation of member function
'c10::optional<caffe2::TypeMeta>::operator->' requested here
return type_meta->toScalarType();
^
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/src/force.cpp:21:
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/m/styles/style_pair.h:71:
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/src/pair_nequip.h:25:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/ATen.h:9:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Context.h:4:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Tensor.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/core/TensorBody.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Operators.h:13:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/Scalar.h:11:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/ScalarType.h:6:
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/Optional.h:730:5: error: use of undeclared identifier 'assert'
assert(initialized());
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/TensorOptions.h:430:32: note: in instantiation of member function
'c10::optional<c10::MemoryFormat>::operator*' requested here
merged.set_memory_format(*optional_memory_format);
^
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/src/force.cpp:21:
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/m/styles/style_pair.h:71:
In file included from /Users/Michael_wang/Documents/venkat/lammps-develop/src/pair_nequip.h:25:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/ATen.h:9:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Context.h:4:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Tensor.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/core/TensorBody.h:3:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/ATen/Operators.h:13:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/Scalar.h:11:
In file included from /Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/ScalarType.h:6:
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/util/Optional.h:730:5: error: use of undeclared identifier 'assert'
assert(initialized());
^
/Users/Michael_wang/anaconda3/envs/wtf4/lib/python3.8/site-packages/torch/include/c10/core/TensorOptions.h:460:17: note: in instantiation of member function
'c10::optional<c10::Device>::operator*' requested here
device_ = *device;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/lammps.dir/Users/Michael_wang/Documents/venkat/lammps-develop/src/force.cpp.o] Error 1
make[1]: *** [CMakeFiles/lammps.dir/all] Error 2
make: *** [all] Error 2
At first, I thought it might be a compiler problem. I tried different versions of Xcode compiler, brew installed llvm compiler, brew installed gcc. None of them works. Any suggestions on what might be the problem? (It works on a Linux machine)
Hi @wuziqi-cmu,
There may be something of use to you in #8 or #10... but as I said there, we do not support macOS. Things may work, but I wouldn't expect it to and we do not support it.
(Note that brew install
ing stuff is not enough to force it to be used, you'd have to set the compiler for cmake... I'd consult the usual sources for more information.)
Got it! Thanks for letting me know. Actually, it was working a few weeks ago, but somehow it started behaving like that. I'll definitely check #8 and #10. If it still fails to compile, I guess I'll keep working on the Linux machine.
btw, the error in #10 can be resolved by changing long
to long long
since Linux and mac understand long differently. Source: https://forums.developer.nvidia.com/t/strange-link-error-seen-by-multiple-people-while-building-pytorch-cpp-cuda-extensions/145261
Hm strange it would stop working... since it's in libtorch
, you could always try building with the pre-built independent libtorch
downloaded from PyTorch (see README
).
Re the error in #10, very good to know— I'd be happy to look over a PR that fixes this by subbing int64_t
if it is in your way, or will eventually get around to it myself.