![]() |
|
![]() |
|
Thread Tools |
![]() |
#1 |
"Ed Hall"
Dec 2009
Adirondack Mtns
524010 Posts |
![]()
(Note: I expect to keep the first post of each of these "How I..." threads up-to-date with the latest version. Please read the rest of each thread to see what may have led to the current set of instructions.)
I will take the liberty of expecting readers to already be somewhat familiar with Google's Colaboratory sessions. There are several threads already on Colab and these should be reviewed by interested readers: Google Colaboratory Notebook? GPU72 Notebook Integration... Notebook Instance Reverse SSH and HTTP Tunnels. Colab question I do not, as of yet, have a github account, so I have not created an upload of this to github. Others may feel free to do so, if desired. The following is a manner to compile and install the GPU branch of GMP-ECM into a Colab session, and then use it to factor composites retrieved from factordb.com. This implementation of GMP-ECM uses the number of available cores as its curve count. Within the below code, the level setting can be used to limit how many steps of the B1 value to try. Additionally, if larger B1 values are of interest, the appropriate values can easily be changed. For those unfamiliar with the GPU branch of GMP-ECM, only stage 1 is handled by the GPU. All of stage 2 is still only processed by the CPU. Additionally, the stages are not run in parallel. Stage 1 runs on the GPU and then stage 2 runs on the CPU. More information on the GPU branch of GMP-ECM can be found in the README.gpu document within the ecm main folder. To use Colab, you need a Gmail account and will be required to log into that account to run a session. On to the specifics: Open a Google Colaboratory session. Sign in with your Google/Gmail account info. Choose New Python3 notebook: Code:
Menu->File->New Python3 notebook (or within popup) Code:
Menu->Runtime->Change runtime type->Hardware accelerator->GPU->SAVE Edit title from Untitled... to whatever you like. Paste the following into the Codeblock: Code:
######################################################### ### This Colaboratory session is designed to retrieve ### ### composites from factordb.com and factor them with ### ### GMP-ECM using the GPU branch. Factors, if found, ### ### are then sent to factordb.* ### ### ### ### To adjust the number of composites to retrieve as ### ### well as the size to retrive, change the variables ### ### below this comment block. The size of the random ### ### number to be used to help avoid collisions (1000) ### ### can also be changed, if desired. ### ### ### ### * Since only GMP-ECM is used, it is possible that ### ### factors may not be found if composites chosen are ### ### too large. To use this for larger composites, B1 ### ### values can be changed within their respective if- ### ### loops. See code near bottom, i.e. 11e4, etc. ### ######################################################### compNum = 3 # Number of composites to run compSize = 84 # Size of composites to run ranNum = 1000 # Number for random count level = 3 # Level to run ( 1 = 11e2, 2 = 11e3, 3 = 11e4, 4 = 43e4, 5+ = 11e5 ) import os import random import subprocess import time import urllib.request #reports factors to factordb def send2db(composite, factors): factorline = str(factors) sendline = 'report=' + str(composite) + '%3D' + factorline dbcall = sendline.encode('utf-8') temp2 = urllib.request.urlopen('http://factordb.com/report.php', dbcall) #process factorT to see if factors were returned from GMP-ECM def factorStr(factorT): factors = str(factorT) ind = factors.rfind("stdout") ind += 9 factors = factors[ind:] factors = factors[:-4] # print(len(factors), len(composite), factors) return factors #checks to see if GMP-ECM already exists #if it does, this portion is skipped exists = os.path.isfile('/usr/local/bin/ecm') if exists < 1: print("Installing system packages. . .") subprocess.call(["chmod", "777", "/tmp"]) subprocess.call(["apt", "update"]) subprocess.call(["apt", "install", "g++", "m4", "make", "git", "libgmp-dev", "libtool", "p7zip", "autoconf", "cuda-10-0"]) #retrieves ecm print("Retrieving GMP-ECM. . .") subprocess.call(["git", "clone", "https://gitlab.inria.fr/zimmerma/ecm", "ecm"]) os.chdir("/content/ecm") subprocess.call(["libtoolize"]) subprocess.call(["autoreconf", "-i"]) subprocess.call(["./configure", "--enable-gpu", "--with-cuda-bin=/usr/local/cuda-10.0/bin", "--with-cuda=/usr/local/cuda-10.0/targets/x86_64-linux", "--with-cuda-lib=/usr/local/cuda-10.0/targets/x86_64-linux/lib", "", "", "", "", "--with-gmp=/usr/local/"]) print("Compiling GMP-ECM. . .") subprocess.call(["make"]) subprocess.call(["make", "install"]) print("Finished installing GMP-ECM. . .") os.chdir("/content") print("Starting the factoring of", compNum, "composites. . .\n") #main loop foundf = 0 for x in range(compNum): randnum = random.randrange(ranNum) #fetch a number from factordb dbcall = 'http://factordb.com/listtype.php?t=3&mindig=' + str(compSize) + '&perpage=1&start=' + str(randnum) + '&download=1' #some file processing to get the number into a format usable by GMP-ECM temp0 = urllib.request.urlopen(dbcall) temp1 = temp0.read() composite = temp1.decode(encoding='UTF-8') composite = composite.strip("\n") fstart = time.time() #print number being worked on print("Composite", x + 1, "is:", composite) factorT = subprocess.run(['ecm', '-gpu', '-q', '11e2'], stdout=subprocess.PIPE, input=temp1) factors = factorStr(factorT) if (len(factors) == len(composite)) and level > 1: print("No factors found at 11e2! Trying 11e3. . .") factorT = subprocess.run(['ecm', '-gpu', '-q', '11e3'], stdout=subprocess.PIPE, input=temp1) factors = factorStr(factorT) if (len(factors) == len(composite)) and level > 2: print("No factors found at 11e3! Trying 11e4. . .") factorT = subprocess.run(['ecm', '-gpu', '-q', '11e4'], stdout=subprocess.PIPE, input=temp1) if (len(factors) == len(composite)) and level > 3: print("No factors found at 11e4! Trying 43e4. . .") factorT = subprocess.run(['ecm', '-gpu', '-q', '43e4'], stdout=subprocess.PIPE, input=temp1) factors = factorStr(factorT) if (len(factors) == len(composite)) and level > 4: print("No factors found at 43e4! Trying 11e5. . .") factorT = subprocess.run(['ecm', '-gpu', '-q', '11e5'], stdout=subprocess.PIPE, input=temp1) factors = factorStr(factorT) if (len(factors) > len(composite)): foundf += 1 factors = factors.replace(' ','*') send2db(composite, factors) print("Factors for", x + 1, ":", factors) else: print("No factors found!") runtime = time.time() - fstart print("Elapsed time was", int(runtime / 60), "minute(s) and", int(runtime % 60), "second(s). So far,", foundf, "of", x + 1, "composites, have been factored.\n") #all numbers are completed print("Found factors for", foundf, "of", compNum, "composites!") Subsequent runs should proceed without the compilation and installation steps. Last fiddled with by EdH on 2023-01-15 at 19:27 |
![]() |
![]() |
![]() |
#2 |
Jan 2023
52 Posts |
![]()
Script currently fails at
Code:
os.chdir("/content/ecm") I was poking around and seeing if I couldn't find a way to run some free ecm curves against some of my favorite composites, and this looks like a great jumping off point! Thanks for writing this up and sharing. Last fiddled with by Tyler Busby on 2023-01-15 at 08:21 |
![]() |
![]() |
![]() |
#3 |
"Ed Hall"
Dec 2009
Adirondack Mtns
23·5·131 Posts |
![]()
Thanks for reporting this. Yes, the location and download method has changed. I will try to correct it soon.
|
![]() |
![]() |
![]() |
#4 |
Jan 2023
52 Posts |
![]()
For what it's worth, it seems simply running
Code:
!apt-get install cuda-10-0 Code:
subprocess.call(["git", "clone", "https://gitlab.inria.fr/zimmerma/ecm", "ecm"]) |
![]() |
![]() |
![]() |
#5 |
"Ed Hall"
Dec 2009
Adirondack Mtns
23×5×131 Posts |
![]()
Thanks! I also changed subversion to git in the install line for apt. My trials with CUDA 11 are failing with:
Code:
checking cuda.h usability... no checking cuda.h presence... yes configure: WARNING: cuda.h: present but cannot be compiled configure: WARNING: cuda.h: check for missing prerequisite headers? configure: WARNING: cuda.h: see the Autoconf documentation configure: WARNING: cuda.h: section "Present But Cannot Be Compiled" configure: WARNING: cuda.h: proceeding with the compiler's result configure: WARNING: ## ----------------------------------- ## configure: WARNING: ## Report this to ecm-discuss@inria.fr ## configure: WARNING: ## ----------------------------------- ## checking for cuda.h... no configure: error: required header file missing |
![]() |
![]() |
![]() |
#6 |
"Ed Hall"
Dec 2009
Adirondack Mtns
23·5·131 Posts |
![]()
That did get it running again for now. I'll work on CUDA 11 later.
Thanks again for the feedback. (I suppose I better look through my other threads. . .) |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How I Create a Colab Session That Factors factordb Composites with YAFU | EdH | EdH | 23 | 2022-09-23 12:36 |
How I Compile the GPU branch of GMP-ECM in a Colaboratory Session | EdH | EdH | 15 | 2021-10-09 13:56 |
Someone is reporting orphan factors to FactorDB. | GP2 | FactorDB | 6 | 2018-07-24 19:45 |
Cunningham Table Composites in FactorDB | Batalov | Cunningham Tables | 15 | 2011-07-30 03:43 |
Factoring of composites with near factors - request for data | AntonVrba | Factoring | 3 | 2006-02-05 06:30 |