Skip to content

Commit

Permalink
Updated CUDALucas install scripts to fix deprecation warnings and CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdulcet committed Sep 15, 2023
1 parent c7d2bd0 commit 513b630
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 44 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CD

on:
push:
branches:
- master
paths:
- '.github/workflows/**'
- 'primenet.py'
Expand All @@ -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:
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions cudalucas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down
13 changes: 7 additions & 6 deletions cudalucas2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions google-colab/GoogleColabGPU.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 8 additions & 3 deletions gpuowl-bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ USE=${3:-ROE1,ROE2}

# GpuOwl arguments
ARGS=(
-device $DEVICE
# -log 10000
-use "$USE"
-device $DEVICE
# -log 10000
-use "$USE"

)

Expand Down Expand Up @@ -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;
Expand Down
22 changes: 11 additions & 11 deletions gpuowl-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

)

Expand Down Expand Up @@ -72,8 +72,8 @@ DEVICE=0

# GpuOwl arguments for all versions
ARGS=(
-device $DEVICE
# -results "$aResultsFile"
-device $DEVICE
# -results "$aResultsFile"

)

Expand Down
1 change: 1 addition & 0 deletions gpuowl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions gpuowl2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions idletime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
1 change: 1 addition & 0 deletions mlucas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 513b630

Please sign in to comment.