2024年6月

CPU使用率高
./build/examples/alpha_zero_torch_example --game=new_game --actors=28 --evaluators=4 --inference_threads=4 --inference_batch_size=1 --train_batch_size=1024 --inference_cache=2621440 --max_simulations=100 --path=./point --checkpoint_freq=10 --max_steps=100 --verbose=false --devices=cuda:0,cpu --replay_buffer_size=655360 --explicit_learning=true

GPU利用率高
./build/examples/alpha_zero_torch_example --game=new_game --actors=20 --inference_batch_size=6 --inference_threads=3 --evaluators=4 --inference_cache=2621440 --max_simulations=100 --path=./point --checkpoint_freq=10 --max_steps=100 --devices=cuda:0,cpu --replay_buffer_size=655360 --explicit_learning=true

查看GPU驱动
watch -n 1 nvidia-smi
watch -n 1 gpustat

安装gpu驱动
sudo apt purge '^nvidia-.*'
sudo apt purge '^cuda-.*'
sudo apt purge '^libcuda.*'
sudo apt autoremove
sudo apt clean
ubuntu-drivers devices
nvcc -V
export PATH=/usr/local/cuda-12.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

开启Cmake 调试日志
-DCMAKE_CXX_FLAGS="-fsanitize=address -g" \
-DCMAKE_CXX_FLAGS_DEBUG="-O0" \

在alpha_zero训练时无法显示错误,如何定位错误
1.检查coredump设置,如果输出为0,则表示coredump被禁用了。
ulimit -c

2.启用coredump
ulimit -c unlimited

3.配置coredump文件的保存位置
echo "/tmp/core.%e.%p" | sudo tee /proc/sys/kernel/core_pattern

4.修改open_spiel/scripts/build_and_run_tests.sh 199行-DBUILD_TYPE=Debug

5.修改open_spiel/CMakeLists.txt 46行,set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")

6.运行gdb ./build/examples/alpha_zero_torch_example /tmp/core.alpha_zero_torc.444708

7.bt显示错误信息

8.frame 0定位错误

9.list 上下文错误位置