Issue
I am using a shared computer with several CPUs, but when I run a notebook it only uses one CPU. Is there any way I can assign the jupyter notebook to use more of the CPUs available?
Solution
A way to "assign" more CPU power to a task is not associated with Jupyter IDE but rather is a library within python. I would recommend using the multiprocessing library. Please refer to this link for the official multiprocessing documentation. A sample code is provided below:
import multiprocessing
def main(number):
print(number)
if __name__ == '__main__':
p1 = Process(target=main, args=(1,))
p2 = Process(target=main, args=(2,))
p1.start()
p2.start()
p1.join()
p2.join()
You can think of each of these processes as more CPU power being used to perform a task.
Answered By - Luke Hamilton
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.