-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v0.17~preview.129.36+325
fails to build on M2 Chip Mac w/ libtorch
2.3.0, OCaml 5.2.0, opam
2.2.1
#14
Comments
TL;DR: same error with Although the current README indicates the compatible version of torch is v2.3: Line 8 in e4d20de
I notice at opam package page for |
TL;DR: same error installing v0.16.0 with I just tried to build v0.16.0 with Click to expand the terminal log
|
I think you'll need 0.17.0 + libtorch 2.3 (see README for current libtorch version). Since we don't publish mac releases of the libtorch opam package anymore, you'll need to uninstall opam torch (and opam libtorch if you have it), download the binaries manually (options 2-4 in README), set the corresponding environment variable, and reinstall opam torch. Do not install opam libtorch. |
As I stated above, I have tried 3 below combinations with option 4 and met the same error.
Besides, there seems to be no |
Here is the error on my machine apple M3 with ocaml-torch v0.17, OCaml 5.2.0, opam 2.2.1. The following actions will be performed:
=== install 1 package
∗ torch v0.17.0 (pinned)
Proceed with ∗ 1 installation? [y/n] y
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
⬇ retrieved torch.v0.17.0 (no changes)
[ERROR] The compilation of torch.v0.17.0 failed at "dune build -p torch -j 15".
#=== ERROR while compiling torch.v0.17.0 ======================================#
# context 2.2.1 | macos/arm64 | ocaml.5.2.0 | pinned(git+https://github.com/janestreet/torch.git#e4d20dea8df4fedeabcf22fd32149ff58108a652)
# path ~/.opam/default/.opam-switch/build/torch.v0.17.0
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p torch -j 15
# exit-code 1
# env-file ~/.opam/log/torch-25252-f5afb6.env
# output-file ~/.opam/log/torch-25252-f5afb6.out
### output ###
# ./torch_api_generated.h:2385:182: note: passing argument to parameter 'pad_mode' here
# [...]
# 129 warnings and 1 error generated.
# (cd _build/default && /Users/ex/.opam/default/bin/ocamlc.opt -w -40 -g -bin-annot -bin-annot-occurrences -I src/torch/.torch.objs/byte -I /Users/ex/.opam/default/lib/base -I /Users/ex/.opam/default/lib/base/base_internalhash_types -I /Users/ex/.opam/default/lib/base/md5 -I /Users/ex/.opam/default/lib/base/shadow_stdlib -I /Users/ex/.opam/default/lib/base_bigstring -I /Users/ex/.opam/default/l[...]
# File "src/torch/optimizer.ml", line 148, characters 18-40:
# 148 | let index = Option.value_local_exn index in
# ^^^^^^^^^^^^^^^^^^^^^^
# Error: Unbound value "Option.value_local_exn"
# (cd _build/default && /Users/ex/.opam/default/bin/ocamlopt.opt -w -40 -g -I src/torch/.torch.objs/byte -I src/torch/.torch.objs/native -I /Users/ex/.opam/default/lib/base -I /Users/ex/.opam/default/lib/base/base_internalhash_types -I /Users/ex/.opam/default/lib/base/md5 -I /Users/ex/.opam/default/lib/base/shadow_stdlib -I /Users/ex/.opam/default/lib/base_bigstring -I /Users/ex/.opam/default/l[...]
# File "src/torch/optimizer.ml", line 148, characters 18-40:
# 148 | let index = Option.value_local_exn index in
# ^^^^^^^^^^^^^^^^^^^^^^
# Error: Unbound value "Option.value_local_exn" I can see the same error for both |
Ok, after warming up some old memory on this code in February and some trial and error, it now builds and runs on my mac. It needs OCaml 5.1.1 because PyML needs 5.1.1 (due to stdcompact). My PR should be agnostic of this. > dune exec examples/basics/basics.exe
cuda available: false
cudnn available: false
42
[ CPUFloatType{} ] |
@ShunchiZhang ah I missed that you had tried that combination already. I've been able to replicate the error now, will try @arbipher's fix |
Hi @mwlon This post was obsolete. See my newer reply. I found another problem that with my fix or the original code that
When using File "src/wrapper/dune", line 4, characters 9-18:
4 | (names torch_api)
^^^^^^^^^
(cd _build/default/src/wrapper && /usr/bin/cc -std=c++17 -fPIC -D_GLIBCXX_USE_CXX11_ABI=1 -isystem /Users/ex/Library/Python/3.12/lib/python/site-packages/torch/include -isystem /Users/ex/Library/Python/3.12/lib/python/site-packages/torch/include/torch/csrc/api/include -g -I /Users/ex/.opam/5.1.1/lib/ocaml -I /Users/ex/.opam/5.1.1/lib/base -I /Users/ex/.opam/5.1.1/lib/base/base_internalhash_types -I /Users/ex/.opam/5.1.1/lib/base/md5 -I /Users/ex/.opam/5.1.1/lib/base/shadow_stdlib -I /Users/ex/.opam/5.1.1/lib/base_quickcheck -I /Users/ex/.opam/5.1.1/lib/base_quickcheck/ppx_quickcheck/runtime -I /Users/ex/.opam/5.1.1/lib/bigarray-compat -I /Users/ex/.opam/5.1.1/lib/bin_prot -I /Users/ex/.opam/5.1.1/lib/bin_prot/shape -I /Users/ex/.opam/5.1.1/lib/ctypes -I /Users/ex/.opam/5.1.1/lib/ctypes-foreign -I /Users/ex/.opam/5.1.1/lib/ctypes/stubs -I /Users/ex/.opam/5.1.1/lib/fieldslib -I /Users/ex/.opam/5.1.1/lib/integers -I /Users/ex/.opam/5.1.1/lib/jane-street-headers -I /Users/ex/.opam/5.1.1/lib/ocaml/str -I /Users/ex/.opam/5.1.1/lib/ocaml/threads -I /Users/ex/.opam/5.1.1/lib/ocaml/unix -I /Users/ex/.opam/5.1.1/lib/ocaml_intrinsics_kernel -I /Users/ex/.opam/5.1.1/lib/parsexp -I /Users/ex/.opam/5.1.1/lib/ppx_assert/runtime-lib -I /Users/ex/.opam/5.1.1/lib/ppx_bench/runtime-lib -I /Users/ex/.opam/5.1.1/lib/ppx_compare/runtime-lib -I /Users/ex/.opam/5.1.1/lib/ppx_enumerate/runtime-lib -I /Users/ex/.opam/5.1.1/lib/ppx_expect/config -I /Users/ex/.opam/5.1.1/lib/ppx_expect/config_types -I /Users/ex/.opam/5.1.1/lib/ppx_expect/make_corrected_file -I /Users/ex/.opam/5.1.1/lib/ppx_expect/runtime -I /Users/ex/.opam/5.1.1/lib/ppx_hash/runtime-lib -I /Users/ex/.opam/5.1.1/lib/ppx_here/runtime-lib -I /Users/ex/.opam/5.1.1/lib/ppx_inline_test/config -I /Users/ex/.opam/5.1.1/lib/ppx_inline_test/runtime-lib -I /Users/ex/.opam/5.1.1/lib/ppx_log/syntax -I /Users/ex/.opam/5.1.1/lib/ppx_log/types -I /Users/ex/.opam/5.1.1/lib/ppx_module_timer/runtime -I /Users/ex/.opam/5.1.1/lib/ppx_sexp_conv/runtime-lib -I /Users/ex/.opam/5.1.1/lib/ppx_stable_witness/runtime -I /Users/ex/.opam/5.1.1/lib/ppx_stable_witness/stable_witness -I /Users/ex/.opam/5.1.1/lib/ppx_string/runtime -I /Users/ex/.opam/5.1.1/lib/ppxlib/print_diff -I /Users/ex/.opam/5.1.1/lib/sexplib -I /Users/ex/.opam/5.1.1/lib/sexplib0 -I /Users/ex/.opam/5.1.1/lib/splittable_random -I /Users/ex/.opam/5.1.1/lib/stdio -I /Users/ex/.opam/5.1.1/lib/stdlib-shims -I /Users/ex/.opam/5.1.1/lib/time_now -I /Users/ex/.opam/5.1.1/lib/typerep -I /Users/ex/.opam/5.1.1/lib/variantslib -I ../bindings -o torch_api.o -c torch_api.cpp)
torch_api.cpp:903:10: fatal error: 'torch_api_generated.cpp' file not found
903 | #include "torch_api_generated.cpp"
| ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
-> required by _build/default/src/wrapper/torch_api.o
-> required by _build/default/src/wrapper/dlltorch_core_stubs.so
-> required by _build/install/default/lib/stublibs/dlltorch_core_stubs.so
-> required by _build/default/torch.install
-> required by alias install |
I cannot use my mac with M3 in the weekend but I tested it with my wsl. Now both There is a subtle concern on my editing in (flags
;-Wincompatible-pointer-types ; if using gcc
-Wno-error=incompatible-function-pointer-types ; if using clang
) however, I cannot figure out how to write the correct stanza for these conditional flags. It will only bother gcc users. |
It also works with my OCaml 5.2.0. PyML is only used in some examples so it's not required if users just install this package (or |
I've released a fix internally, borrowing from @arbipher's PR. It should propagate out later. I'll try to get a corrected version 0.17.1 released later as well. |
Follow the instructions in #2:
I run:
and get the following error:
Click to expand the terminal log
All of this is done at my MacBook Air with M2 chip. The version of OCaml and
opam
shows as follows:Thank you for helping me to resolve this issue :)
The text was updated successfully, but these errors were encountered: