openmc icon indicating copy to clipboard operation
openmc copied to clipboard

`openmc.deplete` incompatible with Apple M1

Open kkiesling opened this issue 3 years ago • 2 comments

When trying to import openmc.deplete on a Mac computer with the Apple M1 chip, the following error occurs:

Traceback (most recent call last):
  File "/Users/kkiesling/software/opt/depletion-comparison/pwr/openmc/run_depletion.py", line 5, in <module>
    import openmc.deplete
  File "/Users/kkiesling/software/opt/openmc/openmc/deplete/__init__.py", line 11, in <module>
    from .coupled_operator import *
  File "/Users/kkiesling/software/opt/openmc/openmc/deplete/coupled_operator.py", line 21, in <module>
    import openmc.lib
  File "/Users/kkiesling/software/opt/openmc/openmc/lib/__init__.py", line 32, in <module>
    _dll = CDLL(_filename)
  File "/Users/kkiesling/opt/anaconda3/envs/openmc-dev/lib/python3.10/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Users/kkiesling/software/opt/openmc/openmc/lib/libopenmc.dylib, 0x0006): tried: '/Users/kkiesling/software/opt/openmc/openmc/lib/libopenmc.dylib' (mach-o file, but is an incompatible architecture (have (arm64), need (x86_64)))

I have no issue importing other standard openmc modules to build a model and run an eigenvalue problem. It is just this one module (could be others but I haven't encountered the error elsewhere). OpenMC compiles fine, this error occurs at runtime.

Other info/things I have tried:

  • I am compiling from source with the latest develop branch.
  • I have played around with explicitly setting different compilers (tried gcc/g++ and clang/clang++, both from various locations on my computer).
  • I have tried explicitly setting the CMAKE_OSX_ARCHITECTURES to "arm64" (what it is using) and "x86_64" per some google solutions but trying to set the architecture to the latter causes other errors and fails during build.

I am out of ideas for how to fix this on my end and I am not even sure if this is something that can be addressed by OpenMC (maybe there is something to set in CMake but my searching has led to no solutions on this front).

Has anyone else experienced this error with M1 and know how to get around it?

kkiesling avatar Oct 24 '22 17:10 kkiesling

Other info: the conda install (conda install openmc=0.13.2=*mpich*) seems to be fine

kkiesling avatar Oct 24 '22 17:10 kkiesling

I have gotten openmc.deplete to work on my M1 MBP for OpenMC version 0.14.0, with

CC=/opt/homebrew/opt/llvm/bin/clang CXX=/opt/homebrew/opt/llvm/bin/clang++ LDFLAGS=-L/usr/local/lib cmake -DCMAKE_INSTALL_PREFIX=$HOME/openmc ..

for OpenMP, and

HDF5_ROOT=/opt/homebrew CXX=/opt/homebrew CC=/opt/homebrew/opt/llvm/bin/clang CXX=/opt/homebrew/opt/llvm/bin/clang++ LDFLAGS=-L/usr/local/lib cmake -DCMAKE_INSTALL_PREFIX=$HOME/openmc-mpi -DOPENMC_USE_MPI=ON -DOPENMC_USE_OPENMP=OFF ..

for MPI.

I am, however having other difficulties with openmc.deplete, namely that it doesn't seem to be depleting anything, see Depletion calculations do not deplete

Kladdy avatar Jan 29 '24 16:01 Kladdy