Sinisterly
StringCalculationWithGPU - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Python (https://sinister.ly/Forum-Python)
+--- Thread: StringCalculationWithGPU (/Thread-StringCalculationWithGPU)



StringCalculationWithGPU - Mansispicher39 - 08-15-2018

Hello developers, I have a stupid question Biggrin Can you create Py script that processes txt file on the GPU and deletes for example the row if there is the word 'sinister' for an example and it contains 30 mill rows. Would it be faster than the GPU and can you do that at all (if the CPU runs only one process with the script)

[Image: hungry-ladybug-43.localtunnel.me]

Confused Confused Confused


RE: StringCalculationWithGPU - DedSpace - 08-15-2018

(08-15-2018, 03:52 PM)Mansispicher39 Wrote: Hello developers, I have a stupid question Biggrin Can you create Py script that processes txt file on the GPU and deletes for example the row if there is the word 'sinister' for an example and it contains 30 mill rows. Would it be faster than the GPU and can you do that at all (if the CPU runs only one process with the script)

[Image: funny-pug-38.localtunnel.me]

Confused  Confused  Confused

you should search for "pycuda" if you have nvidia GPU. else you should look at PyOpenCL.

basic way to play with files is:

Code:
a = open("filename.extension", "rw") b = open("output.txt", "w") for line in a.readlines(): #go through each line    if line != match:        b.writelines(line) #only write the lines that dont have what you look for

This will leave you with 2 files, but you can easily delete the first one and you are left with the one you want. "match" should be a regular expression (more reading yay!) so it can find what you are looking for even if there is lots of text on the line. parallel computing (what a gpu is useful for) will not be this simple but at least you have some where to start

have fun Smile