LeelaChessZero / lc0

The rewritten engine, originally for tensorflow. Now all other backends have been ported here.
GNU General Public License v3.0
2.47k stars 534 forks source link

Link errors lc0 on Pi4 #1404

Closed p2dewit closed 4 years ago

p2dewit commented 4 years ago

When following Pi4 compile description using latest lc0 clone (and full updated buster) results in link errors.[110/133] Linking target lc0 FAILED: lc0 clang++-6.0 -o lc0 lc0.p/src_main.cc.o lc0.p/src_utils_protomessage.cc.o lc0.p/src_engine.cc.o lc0.p/src_version.cc.o lc0.p/src_benchmark_backendbench.cc.o lc0.p/src_benchmark_benchmark.cc.o lc0.p/src_chess_bitboard.cc.o lc0.p/src_chess_board.cc.o lc0.p/src_chess_position.cc.o lc0.p/src_chess_uciloop.cc.o lc0.p/src_mcts_node.cc.o lc0.p/src_mcts_params.cc.o lc0.p/src_mcts_search.cc.o lc0.p/src_mcts_stoppers_common.cc.o lc0.p/src_mcts_stoppers_factory.cc.o lc0.p/src_mcts_stoppers_legacy.cc.o lc0.p/src_mcts_stoppers_alphazero.cc.o lc0.p/src_mcts_stoppers_smooth.cc.o lc0.p/src_mcts_stoppers_stoppers.cc.o lc0.p/src_mcts_stoppers_timemgr.cc.o lc0.p/src_neural_cache.cc.o lc0.p/src_neural_encoder.cc.o lc0.p/src_neural_factory.cc.o lc0.p/src_neural_loader.cc.o lc0.p/src_neural_network_check.cc.o lc0.p/src_neural_network_demux.cc.o lc0.p/src_neural_network_legacy.cc.o lc0.p/src_neural_network_mux.cc.o lc0.p/src_neural_network_random.cc.o lc0.p/src_neural_network_record.cc.o lc0.p/src_neural_network_rr.cc.o lc0.p/src_neural_writer.cc.o lc0.p/src_selfplay_game.cc.o lc0.p/src_selfplay_loop.cc.o lc0.p/src_selfplay_tournament.cc.o lc0.p/src_syzygy_syzygy.cc.o lc0.p/src_utils_commandline.cc.o lc0.p/src_utils_configfile.cc.o lc0.p/src_utils_esc_codes.cc.o lc0.p/src_utils_histogram.cc.o lc0.p/src_utils_logging.cc.o lc0.p/src_utils_optionsdict.cc.o lc0.p/src_utils_optionsparser.cc.o lc0.p/src_utils_random.cc.o lc0.p/src_utils_string.cc.o lc0.p/src_utils_weights_adapter.cc.o lc0.p/src_utils_filesystem.posix.cc.o lc0.p/src_neural_blas_convolution1.cc.o lc0.p/src_neural_blas_fully_connected_layer.cc.o lc0.p/src_neural_blas_se_unit.cc.o lc0.p/src_neural_blas_network_blas.cc.o lc0.p/src_neural_blas_winograd_convolution3.cc.o lc0.p/src_neural_opencl_network_opencl.cc.o lc0.p/src_neural_opencl_OpenCL.cc.o lc0.p/src_neural_opencl_OpenCLTuner.cc.o lc0.p/src_neural_opencl_OpenCLBuffers.cc.o lc0.p/src_neural_shared_activation.cc.o lc0.p/src_neural_shared_winograd_filter.cc.o -flto -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -pthread -Wl,--start-group /usr/lib/libopenblas.so /usr/bin/../lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/libOpenCL.so /usr/lib/arm-linux-gnueabihf/libz.so -Wl,--end-group clang: error: unable to execute command: Segmentation fault clang: error: linker command failed due to signal (use -v to see invocation) [115/133] Compiling C++ object liblc0_lib.a.p/src_neural_opencl_OpenCL.cc.o ninja: build stopped: subcommand failed.

Naphthalin commented 4 years ago
Lc0 requires C++17 now. Minimum compiler versions:
Visual Studio: 2017
g++: v8.0
clang: v5.0
(you probably need to delete build/release after upgrading)

What version of g++ and ninja do you have?

p2dewit commented 4 years ago

g++ version 8.3.0 ninja version 1.10.0

p2dewit commented 4 years ago

clang v6.0.1 Deleting build/release does not help.

ScallyBag commented 4 years ago

Hi,

Lc0 compiles fine on my RPi 4 with gcc-8.3.0 and ninja 1.8.2

Al.

Sent from Scally's iPhone 11 Pro

On 26 Jul 2020, at 12:24, p2dewit notifications@github.com wrote:

 g++ version 8.3.0 ninja version 1.10.0

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

p2dewit commented 4 years ago

HI, Worked with me fine as well, until i completely redid all the prescribed steps as in the README.md on a fresh SD card with the latest git clone yesterday (25/7) (which gave me the latest versions of meson and ninja and clang v6.0 and the link errors). Pi steps not updated in line with latest changes ?

borg323 commented 4 years ago

My guess is you run out of memory during compilation. You can try to do a ninja -j 1 in the build directory.

p2dewit commented 4 years ago

ninja -j 1 gives the same result (linking failed). Memory usage not going much over 10%, so does not seem the issue. Will try on a Pi with more memory though (just to be sure).

Update: Tried on a Pi4 4GB and same result.

borg323 commented 4 years ago

Then it may be a clang issue - after all, it is a segmentation fault, not some build error. Can you try building with gcc? You need to clear the build directory, changing compiler after the initial configuration is not supported.

p2dewit commented 4 years ago

Switched to gcc. After resolving the libatomic dependency by adding it to meson.build all went fine and the build was successful.

vishwanathan-iyer commented 4 years ago

@p2dewit Can you please share how to resolve libatomic dependency in meson.build?

borg323 commented 4 years ago

Can you try adding the following after line 512 of meson.build: deps += cc.find_library('libatomic', required: false)