starkware-libs / stone-prover

Apache License 2.0
256 stars 76 forks source link

Can't build docker image on M1 macbook #1

Open delaaxe opened 1 year ago

delaaxe commented 1 year ago

Running the command docker build --tag prover . fails at the step RUN ctest -V:

Screenshot 2023-09-01 at 10 05 03
...
#16 14.34 test 83
#16 14.34       Start 83: serialization_test
#16 14.34 
#16 14.34 83: Test command: /app/build/Release/src/starkware/utils/serialization_test
#16 14.34 83: Working Directory: /app/build/Release/src/starkware/utils
#16 14.34 83: Test timeout computed to be: 1500
#16 14.47 83: [==========] Running 7 tests from 3 test cases.
#16 14.47 83: [----------] Global test environment set-up.
#16 14.47 83: [----------] 3 tests from SerializationTest/0, where TypeParam = unsigned int
#16 14.47 83: [ RUN      ] SerializationTest/0.SerializeDeserialize
#16 14.48 83: E0901 07:05:05.212533   260 prng.cc:62] Seeding PRNG with 0x1780b47c26da4aae
#16 14.48 83: qemu: uncaught target signal 4 (Illegal instruction) - core dumped
#16 14.48 83/84 Test #83: serialization_test .................***Exception: Illegal  0.14 sec
...
#16 14.43 The following tests FAILED:
#16 14.43         1 - trace_test (ILLEGAL)
#16 14.43         2 - air_test_utils_test (ILLEGAL)
#16 14.43         4 - boundary_air_test (ILLEGAL)
#16 14.43         5 - boundary_periodic_column_test (ILLEGAL)
#16 14.43         6 - cpu_air_test (ILLEGAL)
#16 14.43         8 - diluted_check_cell_test (ILLEGAL)
#16 14.43         9 - diluted_check_test (ILLEGAL)
#16 14.43        10 - memory_cell_test (ILLEGAL)
#16 14.43        11 - range_check_cell_test (ILLEGAL)
#16 14.43        12 - permutation_dummy_air_test (ILLEGAL)
#16 14.43        13 - degree_three_example_air_test (ILLEGAL)
#16 14.43        14 - fibonacci_air_test (ILLEGAL)
#16 14.43        15 - field_operations_test (ILLEGAL)
#16 14.43        16 - field_operations_axioms_test (ILLEGAL)
#16 14.43        17 - field_element_base_test (ILLEGAL)
#16 14.43        18 - big_int_test (ILLEGAL)
#16 14.43        19 - polynomials_test (ILLEGAL)
#16 14.43        22 - list_of_cosets_test (ILLEGAL)
#16 14.43        23 - elliptic_curve_test (ILLEGAL)
#16 14.43        24 - fft_test (ILLEGAL)
#16 14.43        25 - test_field_element_test (ILLEGAL)
#16 14.43        27 - prime_field_element_test (ILLEGAL)
#16 14.43        28 - fraction_field_element_test (ILLEGAL)
#16 14.43        29 - extension_field_element_test (ILLEGAL)
#16 14.43        30 - field_operations_helper_test (ILLEGAL)
#16 14.43        31 - lde_test (ILLEGAL)
#16 14.43        32 - cached_lde_manager_test (ILLEGAL)
#16 14.43        33 - field_element_test (ILLEGAL)
#16 14.43        34 - field_test (ILLEGAL)
#16 14.43        35 - field_element_vector_test (ILLEGAL)
#16 14.43        41 - channel_test (ILLEGAL)
#16 14.43        42 - proof_of_work_test (ILLEGAL)
#16 14.43        43 - table_prover_impl_test (ILLEGAL)
#16 14.43        44 - parallel_table_prover_test (ILLEGAL)
#16 14.43        45 - table_verifier_impl_test (ILLEGAL)
#16 14.43        46 - packaging_commitment_scheme_test (ILLEGAL)
#16 14.43        47 - commitment_scheme_test (ILLEGAL)
#16 14.43        48 - caching_commitment_scheme_test (ILLEGAL)
#16 14.43        49 - merkle_test (ILLEGAL)
#16 14.43        50 - periodic_column_test (ILLEGAL)
#16 14.43        51 - multiplicative_neighbors_test (ILLEGAL)
#16 14.43        52 - composition_polynomial_test (ILLEGAL)
#16 14.43        53 - breaker_test (ILLEGAL)
#16 14.43        54 - utils_test (ILLEGAL)
#16 14.43        55 - keccak_256_test (ILLEGAL)
#16 14.43        56 - masked_hash_test (ILLEGAL)
#16 14.43        60 - fft_domain_test (ILLEGAL)
#16 14.43        61 - fft_bases_test (ILLEGAL)
#16 14.43        62 - fri_test (ILLEGAL)
#16 14.43        63 - fri_layer_test (ILLEGAL)
#16 14.43        64 - fri_committed_layer_test (ILLEGAL)
#16 14.43        67 - prng_test (ILLEGAL)
#16 14.43        68 - hash_chain_test (ILLEGAL)
#16 14.43        69 - committed_trace_test (ILLEGAL)
#16 14.43        70 - composition_oracle_test (ILLEGAL)
#16 14.43        71 - oods_test (ILLEGAL)
#16 14.43        72 - stark_test (ILLEGAL)
#16 14.43        73 - stark_params_test (ILLEGAL)
#16 14.43        80 - bit_reversal_test (ILLEGAL)
#16 14.43        82 - to_from_string_test (ILLEGAL)
#16 14.43        83 - serialization_test (ILLEGAL)
#16 14.44 Errors while running CTest
#16 14.44 Output from these tests are in: /app/build/Release/Testing/Temporary/LastTest.log
#16 14.44 Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
------
executor failed running [/bin/sh -c ctest -V]: exit code: 8
voidcenter commented 1 year ago

I have the same issue

delaaxe commented 1 year ago

I think it's only meant for Linux at the moment

d-roak commented 1 year ago

The docker base image is only available for amd64, the M1 architecture is arm64. You can tweak it to build for arm64, but you will come across with inline assembly that is incompatible, and it will crash while you are trying to build it

When you are running it, you are actually running it on a virtualized env (likely qemu)

iliav-starkware commented 1 year ago

@delaaxe @voidcenter @d-roak There will soon be a release that removes the assembly in question, allowing for the docker image to be built on arm64 (I successfully built it on an M1 Mac).

iliav-starkware commented 1 year ago

@delaaxe @voidcenter @d-roak it should now be possible to build the docker on M1 Mac. Please confirm so the issue can be closed.

d-roak commented 1 year ago

@iliav-starkware can you tell me which commit fixed the M1 Mac docker build and what was the change that fixed it? It seems that you are still using inline assembly on some files e.g. src/starkware/algebra/fields/prime_field_element.S

d-roak commented 1 year ago

Just saw the --build-arg CMAKE_ARGS=-DNO_AVX=1 added flag

iliav-starkware commented 1 year ago

@d-roak is it working?

delaaxe commented 1 year ago

@iliav-starkware it still fails for me, i'll try again from scratch but full build takes 3h+ on my laptop

d-roak commented 1 year ago

@iliav-starkware tl;dr: no

The base image continues to be an amd64 image, so you will build it in a virtualized environment that will take a LONG time to build, and according to @delaaxe, it still fails

If u change the base image to one that can build on aarch64, and pass the new --build-arg CMAKE_ARGS=-DNO_AVX=1, it will stop having the inline assembly issue, but it will fail while building the the blake2 dependency. If you want, I can open a PR with the tweaks for building the aarch64 docker image for you to test around

delaaxe commented 1 year ago

I confirm still same error

Subbitoooo commented 1 year ago

Good afternoon Guys, You can try to Follow this algorithm! 1)Install Docker Desktop for Mac: Ensure that you have Docker Desktop installed on your M1 MacBook. Docker Desktop for Mac supports both Intel and ARM64 architectures.

2)Configure Docker CLI for ARM64: Open Terminal and run the following command to configure Docker CLI to use the ARM64 architecture:

bash Copy code docker run --rm --privileged docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64 3)Build Docker Image: Navigate to the directory containing your Dockerfile and application code. Run the following command to build the Docker image:

bash Copy code docker build -t your_image_name . 4)Run Docker Container: Once the image is built, you can run a container from it:

bash Copy code docker run -p 8080:80 your_image_name Adjust the ports and other options according to your application.

5)Test the Container: Open a web browser or use a tool like curl to test your application running inside the Docker container. Enjoy!

d-roak commented 1 year ago

Hum.. Chat gpt?

orangee0721 commented 12 months ago

try chat gpt

d-roak commented 12 months ago

that won't work, i can say it with confidence without trying 😅

iliav-starkware commented 12 months ago

@iliav-starkware tl;dr: no

The base image continues to be an amd64 image, so you will build it in a virtualized environment that will take a LONG time to build, and according to @delaaxe, it still fails

If u change the base image to one that can build on aarch64, and pass the new --build-arg CMAKE_ARGS=-DNO_AVX=1, it will stop having the inline assembly issue, but it will fail while building the the blake2 dependency. If you want, I can open a PR with the tweaks for building the aarch64 docker image for you to test around

What blake dependency? Can you elaborate?

d-roak commented 12 months ago

I deleted the repo from my laptop so I can't reproduce it to check the exact error. But there was some error while compiling this file: https://github.com/starkware-libs/stone-prover/blob/main/src/third_party/blake2/blake2s.c

But this error is only relevant if you want to port your docker configuration to work both on amd64 and aarch64 natively. Your current approach seems to be working natively on amd64 and virtualized on aarch64, for that I don't know the exact error. @delaaxe might be able to give you more details on that since he tested it

LandauRaz commented 3 months ago

Closed due to inactivity.

d-roak commented 3 months ago

I didn't follow up on the issue in the latest updates, but if it was not marked as solved, it seems weird to close it due to inactivity. The latest answers were not dismissed with a solution or a won't fix.

LandauRaz commented 3 months ago

Apologies, the message was intended for another PR. Installation is only possible on Linux platforms and support for other platforms is WIP. I'll reopen this issue in the meantime.

OwnerOfJK commented 3 weeks ago

Just wanted to add my comments here:

  1. It would be awesome to have an arm64 compatible docker base image for stone that I can build locally.
  2. In the meantime, I have found this alternative that I have been using: https://hub.docker.com/r/maksimryndin/starknet-stone .

While it's slow, it works.