Keytoyze / Mug-Diffusion

High-quality and controllable charting AI for rhythm games, modifed from stable diffusion
MIT License
196 stars 17 forks source link

Any way to build MinaCalc on arm64(mac)? #2

Closed luojunyuan closed 1 year ago

luojunyuan commented 1 year ago

Sorry to bother you. If this is not mean to be solved. Feel free to close.

Building wheels for collected packages: MinaCalc
  Building wheel for MinaCalc (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Library/Developer/CommandLineTools/usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/rr/9z6j7fc16q9grp79wl03sts80000gn/T/pip-req-build-izrdvzn1/setup.py'"'"'; __file__='"'"'/private/var/folders/rr/9z6j7fc16q9grp79wl03sts80000gn/T/pip-req-build-izrdvzn1/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/rr/9z6j7fc16q9grp79wl03sts80000gn/T/pip-wheel-um26pfkd
       cwd: /private/var/folders/rr/9z6j7fc16q9grp79wl03sts80000gn/T/pip-req-build-izrdvzn1/
  Complete output (92 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'minacalc' extension
  creating build
  creating build/temp.macosx-10.9-universal2-3.9
  creating build/temp.macosx-10.9-universal2-3.9/MinaCalc
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -Wno-error=unreachable-code -UNDEBUG -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/include/python3.9 -c MinaCalc/MinaCalc.cpp -o build/temp.macosx-10.9-universal2-3.9/MinaCalc/MinaCalc.o -std=c++17
  In file included from MinaCalc/MinaCalc.cpp:2:
  In file included from MinaCalc/Ulbu.h:9:
  In file included from MinaCalc/Agnostic/HA_PatternMods/Stream.h:2:
  In file included from MinaCalc/Agnostic/HA_PatternMods/../../PatternModHelpers.h:6:
  /Library/Developer/CommandLineTools/usr/lib/clang/14.0.3/include/xmmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
  #error "This header is only meant to be used on x86 and x64 architecture"
   ^
luojunyuan commented 1 year ago

i'm dumb

Keytoyze commented 1 year ago

@luojunyuan 这个问题解决了吗?我还准备今晚看一下,应该是某个宏在mac上不能编译

luojunyuan commented 1 year ago

没有解决

Keytoyze commented 1 year ago

@luojunyuan 请切换到 try-fix-minacalc 分支尝试一下能否编译:

git checkout try-fix-minacalc
luojunyuan commented 1 year ago

无事编译!在ffmepg漫长的安装之后,可以用cpu运行了。2分钟长度的歌曲90秒以内就能完成charting。


来自cuda的警告,这应该属于另一个问题。

Traceback (most recent call last):
  File "/Users/kimika/Downloads/Mug-Diffusion/webui.py", line 14, in <module>
    torch.cuda.init()
  File "/Users/kimika/Library/Python/3.9/lib/python/site-packages/torch/cuda/__init__.py", line 216, in init
    _lazy_init()
  File "/Users/kimika/Library/Python/3.9/lib/python/site-packages/torch/cuda/__init__.py", line 239, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
WARNING: CUDA GPU is not available. Fallback to CPU mode, which may be slow!

如果可以把后端 gpu 切换到 mps的话,应该可以解决这个速度更快更完美吧。我不知道源代码需要做哪些变动。

Keytoyze commented 1 year ago

你的 torch 是 MPS 后端的吗?可以参考 https://pytorch.org/docs/stable/notes/mps.html 来看看怎么改,主要是修改 webui.py 里和 CUDA 相关的代码。