Jittor / JittorLLMs

计图大模型推理库,具有高性能、配置要求低、中文支持好、可移植等特点
Apache License 2.0
2.37k stars 183 forks source link

Mac m1 run cmd failed "/usr/bin/clang++" #20

Open charlie-captain opened 1 year ago

charlie-captain commented 1 year ago

OS: Mac ventura 13.4 beta on Mac mini m1 Command: python3 cli_demo.py chatglm

[i 0405 21:30:32.653299 04 compiler.py:955] Jittor(1.3.7.10) src: /Library/Python/3.9/site-packages/jittor
[i 0405 21:30:32.693324 04 compiler.py:956] clang at /usr/bin/clang++(14.0.3)
[i 0405 21:30:32.693533 04 compiler.py:957] cache_path: /Users/charlie/.cache/jittor/jt1.3.7/clang14.0.3/py3.9.6/macOS-13.4-armxff/AppleM1/default
In file included from /Library/Python/3.9/site-packages/jittor/src/utils/cache_compile.cc:12:
In file included from /Library/Python/3.9/site-packages/jittor/src/misc/hash.h:8:
In file included from /Library/Python/3.9/site-packages/jittor/src/common.h:10:
/Library/Python/3.9/site-packages/jittor/src/utils/log.h:138:18: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
        send_log(move(out), level, verbose);
                 ^
                 std::
1 warning generated.
In file included from /Library/Python/3.9/site-packages/jittor/src/utils/log.cc:14:
/Library/Python/3.9/site-packages/jittor/src/utils/log.h:138:18: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
        send_log(move(out), level, verbose);
                 ^
                 std::
/Library/Python/3.9/site-packages/jittor/src/utils/log.cc:195:12: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
    return move(logs);
           ^
           std::
/Library/Python/3.9/site-packages/jittor/src/utils/log.cc:376:19: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
    vprefix_map = move(new_map);
                  ^
                  std::
3 warnings generated.
In file included from /Library/Python/3.9/site-packages/jittor/src/utils/tracer.cc:11:
In file included from /Library/Python/3.9/site-packages/jittor/src/utils/tracer.h:8:
In file included from /Library/Python/3.9/site-packages/jittor/src/common.h:10:
/Library/Python/3.9/site-packages/jittor/src/utils/log.h:138:18: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
        send_log(move(out), level, verbose);
                 ^
                 std::
/Library/Python/3.9/site-packages/jittor/src/utils/tracer.cc:49:9: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
        sprintf(pid_buf, "%d", getpid());
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^
/Library/Python/3.9/site-packages/jittor/src/utils/tracer.cc:145:9: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
        sprintf(pid_buf, "%d", getpid());
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^
/Library/Python/3.9/site-packages/jittor/src/utils/tracer.cc:147:9: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
        sprintf(st_buf, "set backtrace limit %d", trace_depth);
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^
/Library/Python/3.9/site-packages/jittor/src/utils/tracer.cc:213:13: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
            sprintf(syscom,"%s %p -f -p -i -e %.*s", addr2line_path.c_str(), trace[i], p, messages[i]);
            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^
5 warnings generated.
In file included from /Library/Python/3.9/site-packages/jittor/src/utils/jit_utils.cc:7:
In file included from /Library/Python/3.9/site-packages/jittor/src/utils/cache_compile.h:8:
In file included from /Library/Python/3.9/site-packages/jittor/src/common.h:10:
/Library/Python/3.9/site-packages/jittor/src/utils/log.h:138:18: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
        send_log(move(out), level, verbose);
                 ^
                 std::
In file included from /Library/Python/3.9/site-packages/jittor/src/utils/jit_utils.cc:8:
In file included from /Library/Python/3.9/site-packages/jittor/src/pyjt/py_converter.h:17:
/Library/Python/3.9/site-packages/jittor/src/profiler/simple_profiler.h:48:48: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
    inline SimpleProfiler(string&& name): name(move(name)), cnt(0), total_ns(0), sum(0) {}
                                               ^
                                               std::
In file included from /Library/Python/3.9/site-packages/jittor/src/utils/jit_utils.cc:8:
/Library/Python/3.9/site-packages/jittor/src/pyjt/py_converter.h:358:16: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
        return move(fetch_sync({ptr}).at(0));
               ^
               std::
/Library/Python/3.9/site-packages/jittor/src/utils/jit_utils.cc:505:37: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
                return to_py_object(move(ret));
                                    ^
                                    std::
4 warnings generated.
In file included from /Library/Python/3.9/site-packages/jittor/src/utils/str_utils.cc:8:
In file included from /Library/Python/3.9/site-packages/jittor/src/utils/str_utils.h:8:
In file included from /Library/Python/3.9/site-packages/jittor/src/common.h:10:
/Library/Python/3.9/site-packages/jittor/src/utils/log.h:138:18: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
        send_log(move(out), level, verbose);
                 ^
                 std::
1 warning generated.
ld: library not found for -lomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Traceback (most recent call last):
  File "/Users/charlie/dev/JittorLLMs/cli_demo.py", line 8, in <module>
    model = models.get_model(args)
  File "/Users/charlie/dev/JittorLLMs/models/__init__.py", line 38, in get_model
    globals()[f"get_{model_name}"]()
  File "/Users/charlie/dev/JittorLLMs/models/util.py", line 51, in get_chatglm
    new_path.append(download_fromhub(f"jittorhub://{f}", tdir="chat-glm"))
  File "/Users/charlie/dev/JittorLLMs/models/util.py", line 5, in download_fromhub
    import jittor as jt
  File "/Library/Python/3.9/site-packages/jittor/__init__.py", line 18, in <module>
    from . import compiler
  File "/Library/Python/3.9/site-packages/jittor/compiler.py", line 1189, in <module>
    check_cache_compile()
  File "/Library/Python/3.9/site-packages/jittor/compiler.py", line 884, in check_cache_compile
    recompile = compile(cc_path, cc_flags+f" {opt_flags} ", files, jit_utils.cache_path+'/jit_utils_core'+extension_suffix, True)
  File "/Library/Python/3.9/site-packages/jittor/compiler.py", line 126, in compile
    return do_compile(fix_cl_flags(cmd))
  File "/Library/Python/3.9/site-packages/jittor/compiler.py", line 91, in do_compile
    run_cmd(cmd)
  File "/Library/Python/3.9/site-packages/jittor_utils/__init__.py", line 188, in run_cmd
    raise Exception(err_msg)
Exception: Run cmd failed: "/usr/bin/clang++" "/Library/Python/3.9/site-packages/jittor/src/utils/cache_compile.cc" "/Library/Python/3.9/site-packages/jittor/src/utils/log.cc" "/Library/Python/3.9/site-packages/jittor/src/utils/tracer.cc" "/Library/Python/3.9/site-packages/jittor/src/utils/jit_utils.cc" "/Library/Python/3.9/site-packages/jittor/src/utils/str_utils.cc"   -Wall -Wno-unknown-pragmas -std=c++14 -fPIC  -mcpu=apple-m2  -fdiagnostics-color=always  -undefined dynamic_lookup -lomp  -lstdc++ -ldl -shared  -I"/Library/Python/3.9/site-packages/jittor/src" -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers  -O2   -o "/Users/charlie/.cache/jittor/jt1.3.7/clang14.0.3/py3.9.6/macOS-13.4-armxff/AppleM1/default/jit_utils_core.cpython-39-darwin.so"
lzhengning commented 1 year ago

It seems that openmp library is missing. Please check that if libomp is installed on your macOS. https://github.com/Jittor/jittor#macos-install

charlie-captain commented 1 year ago

It seems that openmp library is missing. Please check that if libomp is installed on your macOS. https://github.com/Jittor/jittor#macos-install

[i 0406 14:10:18.955224 00 compiler.py:955] Jittor(1.3.7.12) src: /Users/charlie/Library/Python/3.9/lib/python/site-packages/jittor
[i 0406 14:10:18.968711 00 compiler.py:956] clang at /usr/bin/clang++(14.0.3)
[i 0406 14:10:18.968768 00 compiler.py:957] cache_path: /Users/charlie/.cache/jittor/jt1.3.7/clang14.0.3/py3.9.6/macOS-13.4-armxff/AppleM1/default
[i 0406 14:10:19.165329 00 __init__.py:227] Total mem: 16.00GB, using 5 procs for compiling.
[i 0406 14:10:19.322852 00 jit_compiler.cc:28] Load cc_path: /usr/bin/clang++
[i 0406 14:10:20.629825 00 compile_extern.py:522] mpicc not found, distribution disabled.
Explicitly passing a `revision` is encouraged when loading a model with custom code to ensure no malicious code has been contributed in a newer revision.
Explicitly passing a `revision` is encouraged when loading a configuration with custom code to ensure no malicious code has been contributed in a newer revision.
Explicitly passing a `revision` is encouraged when loading a model with custom code to ensure no malicious code has been contributed in a newer revision.
Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:19<00:00,  2.47s/it]
Traceback (most recent call last):
  File "/Users/charlie/dev/JittorLLMs/web_demo.py", line 26, in <module>
    model = models.get_model(args)
  File "/Users/charlie/dev/JittorLLMs/models/__init__.py", line 42, in get_model
    return module.get_model(args)
  File "/Users/charlie/dev/JittorLLMs/models/chatglm/__init__.py", line 48, in get_model
    return ChatGLMMdoel(args)
  File "/Users/charlie/dev/JittorLLMs/models/chatglm/__init__.py", line 26, in __init__
    self.model.float32()
  File "/Users/charlie/Library/Python/3.9/lib/python/site-packages/torch/nn/modules/module.py", line 1614, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'ChatGLMForConditionalGeneration' object has no attribute 'float32'