From 513b630dad74370490daa6d5e3006d41ef35e6f0 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Fri, 15 Sep 2023 04:17:14 -0700 Subject: [PATCH] Updated CUDALucas install scripts to fix deprecation warnings and CI. --- .github/workflows/cd.yml | 4 +++- .github/workflows/ci.yml | 21 +++++++++++---------- README.md | 2 ++ cudalucas.sh | 13 +++++++------ cudalucas2.sh | 13 +++++++------ google-colab/GoogleColabGPU.ipynb | 10 +++++----- gpuowl-bench.sh | 11 ++++++++--- gpuowl-wrapper.sh | 22 +++++++++++----------- gpuowl.sh | 1 + gpuowl2.sh | 1 + idletime.sh | 4 ++-- mlucas.sh | 1 + 12 files changed, 59 insertions(+), 44 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 9ab2d578..67c2c10f 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -2,6 +2,8 @@ name: CD on: push: + branches: + - master paths: - '.github/workflows/**' - 'primenet.py' @@ -19,7 +21,7 @@ jobs: architecture: ["x86", "x64"] fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a48bdf7c..244809c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: os: [ubuntu-20.04, ubuntu-22.04] fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Before script run: | sed -i '/^GPU=/,/^fi/ s/^/# /' cudalucas.sh @@ -55,7 +55,7 @@ jobs: env: CXX: ${{ matrix.cxx }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install run: | sudo apt-get -yqq update @@ -92,7 +92,7 @@ jobs: env: CC: ${{ matrix.cc }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Before script run: | sed -i '/^[[:blank:]]*nohup / s/^/# /' mlucas.sh @@ -137,7 +137,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: | python3 -m pip install --upgrade pip @@ -151,13 +151,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: | python3 -m pip install --upgrade pip python3 -m pip install ruff - name: Script - run: ruff --format=github --target-version py37 --select F,E,W,I,D,UP,YTT,S,BLE,B,A,C4,T10,EM,EXE,ISC,ICN,G,PIE,PYI,Q,RSE,RET,SLF,SLOT,SIM,TID,TCH,ARG,PGH,PL,PLC1901,TRY,PERF,RUF --ignore E101,E501,W191,D211,D213,D401,UP004,UP009,UP010,UP024,UP030,UP032,UP036,PLR09,PLR2004,S324,S603,RUF001,RUF002,RUF003,RUF005 . + run: ruff --format=github --target-version py37 --select F,E,W,I,D,UP,YTT,S,BLE,B,A,C4,T10,EM,EXE,ISC,ICN,G,PIE,PYI,Q,RSE,RET,SLF,SLOT,SIM,TID,TCH,ARG,PGH,PL,TRY,PERF,FURB,RUF --preview --ignore E101,E501,W191,D211,D213,D401,UP004,UP009,UP010,UP024,UP030,UP032,UP036,PYI024,PLR09,PLR2004,S324,S603,RUF001,RUF002,RUF003,RUF005 . continue-on-error: true Linux: @@ -169,7 +169,7 @@ jobs: os: [ubuntu-20.04, ubuntu-22.04] fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: | python3 -m pip install --upgrade pip @@ -186,11 +186,12 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: | - python3 -m pip install --upgrade pip + python -m pip install --upgrade pip python -m pip install requests + python3 -m pip install --upgrade pip python3 -m pip install requests - name: Script run: | @@ -209,7 +210,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/README.md b/README.md index 9fabf6d8..2055f553 100644 --- a/README.md +++ b/README.md @@ -291,6 +291,8 @@ PrimeNet script: * Localize the output into other languages (see [here](https://mersenneforum.org/showthread.php?t=27046)). * Remove the dependency on the Requests library * Adapt Loïc Le Loarer's [test suite](https://github.com/llloic11/primenet/tree/main/tests). +* Add an optional GUI using [Tk](https://en.wikipedia.org/wiki/Tk_(software)) and the [tkinter library](https://docs.python.org/3/library/tkinter.html) +* Add docstrings to all functions General: * Create install script for the [CUDAPm1](https://sourceforge.net/projects/cudapm1/) GIMPS program diff --git a/cudalucas.sh b/cudalucas.sh index 43f0bbb1..58ed01f2 100644 --- a/cudalucas.sh +++ b/cudalucas.sh @@ -82,6 +82,7 @@ else wget -nv https://raw.github.com/tdulcet/Distributed-Computing-Scripts/master/primenet.py fi chmod +x primenet.py +python3 -OO -m py_compile primenet.py echo -e "\nInstalling the Requests library\n" # python3 -m ensurepip --default-pip || true python3 -m pip install --upgrade pip || true @@ -128,14 +129,13 @@ if ! COMPUTE=$(/tmp/cudaComputeVersion); then exit 1 fi sed -i "s/--generate-code arch=compute_35,code=sm_35/$COMPUTE/" Makefile -sed -i '/nvmlInit();/d' CUDALucas.cu -sed -i '/nvmlDevice_t device;/d' CUDALucas.cu -sed -i '/nvmlDeviceGetHandleByIndex(device_number, &device);/d' CUDALucas.cu -sed -i '/nvmlDeviceGetUUID(device, uuid, sizeof(uuid)\/sizeof(uuid\[0\]));/d' CUDALucas.cu -sed -i '/nvmlShutdown();/d' CUDALucas.cu # Increase buffers to prevent buffer overflow sed -i 's/file\[32\]/file[268]/g' CUDALucas.cu -sed -i 's/file_bak\[64\]/file_bak[268]/g' CUDALucas.cu +sed -i 's/file_bak\[64\]/file_bak[455]/g' CUDALucas.cu +sed -i 's/chkpnt_sfn\[64\]/chkpnt_sfn[234]/g' CUDALucas.cu +sed -i 's/test\[64\]/test[203]/g' CUDALucas.cu +# Fix deprecation warnings +sed -i '/IniGet/ s/char \?\* \?name/const char* name/; s/char \?\* \?df/const char* df/' parse.{h,c} # make debug make make clean @@ -161,6 +161,7 @@ echo -e "\nStarting PrimeNet\n" nohup python3 -OO primenet.py >> "primenet.out" & sleep 1 echo -e "\nOptimizing CUDALucas for your computer and GPU\nThis may take a while…\n" +timeout -v 60 ./CUDALucas 2976221 || true ./CUDALucas -cufftbench 1024 8192 5 ./CUDALucas -threadbench 1024 8192 5 0 echo -e "\nRunning self tests\nThis will take a while…\n" diff --git a/cudalucas2.sh b/cudalucas2.sh index 1bbf80b3..b886ed3d 100644 --- a/cudalucas2.sh +++ b/cudalucas2.sh @@ -115,14 +115,13 @@ EOF exit 1 fi sed -i "s/--generate-code arch=compute_35,code=sm_35/$COMPUTE/" Makefile - sed -i '/nvmlInit();/d' CUDALucas.cu - sed -i '/nvmlDevice_t device;/d' CUDALucas.cu - sed -i '/nvmlDeviceGetHandleByIndex(device_number, &device);/d' CUDALucas.cu - sed -i '/nvmlDeviceGetUUID(device, uuid, sizeof(uuid)\/sizeof(uuid\[0\]));/d' CUDALucas.cu - sed -i '/nvmlShutdown();/d' CUDALucas.cu # Increase buffers to prevent buffer overflow sed -i 's/file\[32\]/file[268]/g' CUDALucas.cu - sed -i 's/file_bak\[64\]/file_bak[268]/g' CUDALucas.cu + sed -i 's/file_bak\[64\]/file_bak[455]/g' CUDALucas.cu + sed -i 's/chkpnt_sfn\[64\]/chkpnt_sfn[234]/g' CUDALucas.cu + sed -i 's/test\[64\]/test[203]/g' CUDALucas.cu + # Fix deprecation warnings + sed -i '/IniGet/ s/char \?\* \?name/const char* name/; s/char \?\* \?df/const char* df/' parse.{h,c} make make clean fi @@ -137,6 +136,7 @@ else wget -nv https://raw.github.com/tdulcet/Distributed-Computing-Scripts/master/primenet.py fi chmod +x primenet.py + python3 -OO -m py_compile primenet.py fi echo -e "\nInstalling the Requests library\n" # python3 -m ensurepip --default-pip || true @@ -174,6 +174,7 @@ echo -e "\nStarting PrimeNet\n" nohup python3 -OO primenet.py -l "local$N.ini" >> "primenet$N.out" & sleep 1 echo -e "\nOptimizing CUDALucas for your computer and GPU\nThis may take a while…\n" +timeout -v 60 ./CUDALucas 2976221 || true ./CUDALucas -cufftbench 1024 8192 5 ./CUDALucas -threadbench 1024 8192 5 0 echo -e "\nRunning self tests\nThis will take a while…\n" diff --git a/google-colab/GoogleColabGPU.ipynb b/google-colab/GoogleColabGPU.ipynb index ef934dfa..e763ccb4 100644 --- a/google-colab/GoogleColabGPU.ipynb +++ b/google-colab/GoogleColabGPU.ipynb @@ -69,7 +69,7 @@ " '''Run GpuOwl and MPrime.'''\n", " print('\\nStarting PrimeNet\\n')\n", " adir = f'gpuowl/{computer_number}'\n", - " !cd '{adir}'; nohup python3 -OO ../primenet.py --checkin 1 -T {GPU_type_of_work} >> primenet.out &\n", + " !cd '{adir}'; nohup python3 -OO ../primenet.py -T {GPU_type_of_work} >> primenet.out &\n", " !sleep 1\n", " while not os.path.exists(f'{adir}/worktodo.ini'):\n", " print(\"Waiting for 'worktodo.ini' access...\")\n", @@ -122,12 +122,12 @@ " !sed -i '/^crontab / s/^/echo \"Skipped\" # /' gpuowl2.sh # Do not create a cronjob\n", " !bash -- gpuowl2.sh {computer_number} '{prime_ID}' '{computer_name}' {GPU_type_of_work}\n", " file = f'gpuowl/{computer_number}/gpuowl'\n", - " !sed -i '/^ARGS[12]=/a -log 100000' '{file}'\n", - " !sed -i '/^ARGS3=/a -jacobi 100000' '{file}'\n", - " !sed -i '/^ARGS1=/a -mprimeDir ../../mprime_gpu' '{file}'\n", + " !sed -i '/^ARGS[12]=/a \\\\t-log 100000' '{file}'\n", + " !sed -i '/^ARGS3=/a \\\\t-jacobi 100000' '{file}'\n", + " !sed -i '/^ARGS1=/a \\\\t-mprimeDir ../../mprime_gpu' '{file}'\n", " !sed -i 's/0.9/0.95/' '{file}' # Use up to 95% of GPU RAM\n", " print('Registering computer with PrimeNet\\n')\n", - " !cd '{'gpuowl/' + computer_number}' && python3 -OO ../primenet.py -t 0 -W 1 -T {GPU_type_of_work} -u '{prime_ID}' -r 'results.ini' -g -H '{computer_name}'\n", + " !cd '{'gpuowl/' + computer_number}' && python3 -OO ../primenet.py -t 0 --checkin 1 -W 1 -T {GPU_type_of_work} -u '{prime_ID}' -r 'results.ini' -g -H '{computer_name}'\n", "\n", " print('Downloading and setting up Prime95\\n')\n", " !cp Distributed-Computing-Scripts-master/{mprime2.sh,mprime2.exp} .\n", diff --git a/gpuowl-bench.sh b/gpuowl-bench.sh index a29ab517..6352bc98 100644 --- a/gpuowl-bench.sh +++ b/gpuowl-bench.sh @@ -34,9 +34,9 @@ USE=${3:-ROE1,ROE2} # GpuOwl arguments ARGS=( --device $DEVICE -# -log 10000 --use "$USE" + -device $DEVICE + # -log 10000 + -use "$USE" ) @@ -98,6 +98,11 @@ mapfile -t AFFTS < <(echo "$ffts" | numfmt --from=iec) mapfile -t MAX_EXPS < <(echo "$output" | awk -F'[][ ]+' '{ print $5 }' | numfmt --from=si) mapfile -t VARIANTS < <(echo "$output" | sed -n 's/^.*] //p') +echo -e "\nWarming up GPU...\n" +exp=2976221 +"$DIR/$GPUOWL" -prp "$exp" -iters $((ITERS * 10)) -fft 256:3:256 "${ARGS[@]}" +rm -rf -- "$exp" gpuowl.log + for i in "${!MAX_EXPS[@]}"; do if [[ -n $MIN && ${AFFTS[i]} -lt $(( MIN * 1024 )) ]]; then continue; diff --git a/gpuowl-wrapper.sh b/gpuowl-wrapper.sh index ea4eca08..10ab9f2c 100644 --- a/gpuowl-wrapper.sh +++ b/gpuowl-wrapper.sh @@ -22,23 +22,23 @@ DIR3="gpuowl-6" # 1. Current version of GpuOwl (master branch) ARGS1=( -# -mprimeDir ../mprime --unsafeMath -# -use ROE1,ROE2 --use ROE2 + # -mprimeDir ../mprime + -unsafeMath + # -use ROE1,ROE2 + -use ROE2 ) # 2. GpuOwl v7.2-112 ARGS2=( --unsafeMath -# -use STATS + -unsafeMath + # -use STATS ) # 3. GpuOwl v6.11 (v6 branch) ARGS3=( --cleanup --log 10000 -# -use STATS + -cleanup + -log 10000 + # -use STATS ) @@ -72,8 +72,8 @@ DEVICE=0 # GpuOwl arguments for all versions ARGS=( --device $DEVICE -# -results "$aResultsFile" + -device $DEVICE + # -results "$aResultsFile" ) diff --git a/gpuowl.sh b/gpuowl.sh index b9fff122..27580584 100644 --- a/gpuowl.sh +++ b/gpuowl.sh @@ -165,6 +165,7 @@ else wget -nv https://raw.github.com/tdulcet/Distributed-Computing-Scripts/master/primenet.py fi chmod +x primenet.py +python3 -OO -m py_compile primenet.py echo -e "\nInstalling the Requests library\n" # python3 -m ensurepip --default-pip || true python3 -m pip install --upgrade pip || true diff --git a/gpuowl2.sh b/gpuowl2.sh index dd43bbf5..139ca6ff 100644 --- a/gpuowl2.sh +++ b/gpuowl2.sh @@ -198,6 +198,7 @@ else wget -nv https://raw.github.com/tdulcet/Distributed-Computing-Scripts/master/primenet.py fi chmod +x primenet.py + python3 -OO -m py_compile primenet.py fi echo -e "\nInstalling the Requests library\n" # python3 -m ensurepip --default-pip || true diff --git a/idletime.sh b/idletime.sh index 291e861f..09fccaf3 100644 --- a/idletime.sh +++ b/idletime.sh @@ -16,8 +16,8 @@ getSecondsAsDigitalClock() { local sec_num=$1 local d=$(( sec_num / 86400 )) local h=$(( (sec_num % 86400) / 3600 )) - local m=$(( (sec_num % 86400 % 3600) / 60 )) - local s=$(( sec_num % 86400 % 3600 % 60 )) + local m=$(( (sec_num % 3600) / 60 )) + local s=$(( sec_num % 60 )) local text='' if [[ $d -ne 0 ]]; then text+="$(printf "%'d" "$d") days " diff --git a/mlucas.sh b/mlucas.sh index 2ec2166e..e4db5e3d 100644 --- a/mlucas.sh +++ b/mlucas.sh @@ -209,6 +209,7 @@ else wget -nv https://raw.github.com/tdulcet/Distributed-Computing-Scripts/master/primenet.py fi chmod +x primenet.py + python3 -OO -m py_compile primenet.py fi echo -e "\nInstalling the Requests library\n" # python3 -m ensurepip --default-pip || true