Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
并行Python无法看到所有计算机_Python_Python 3.x_Parallel Processing_Parallel Python - Fatal编程技术网

并行Python无法看到所有计算机

并行Python无法看到所有计算机,python,python-3.x,parallel-processing,parallel-python,Python,Python 3.x,Parallel Processing,Parallel Python,我正在尝试在Windows10上将并行Python与Python3.5结合使用。我是新手,所以请原谅这个术语 我已在每台计算机(节点)上安装了Python和所有必需的软件包,并已在每台节点上运行批处理脚本,以使它们对根计算机可见: python ppserver.py -p 35000 -a -w 4 -s "secretword" 我将尝试运行一个简单的示例来解释这个问题,我在internet上找到并编辑了这个示例,它应该可以找到每个节点,但是,只找到了少数几个节点。始终缺少相同的节点: i

我正在尝试在Windows10上将并行Python与Python3.5结合使用。我是新手,所以请原谅这个术语

我已在每台计算机(节点)上安装了Python和所有必需的软件包,并已在每台节点上运行批处理脚本,以使它们对根计算机可见:

python ppserver.py -p 35000 -a -w 4 -s "secretword"
我将尝试运行一个简单的示例来解释这个问题,我在internet上找到并编辑了这个示例,它应该可以找到每个节点,但是,只找到了少数几个节点。始终缺少相同的节点:

import math, time, sys, _thread
import pp
import numpy as np
import pandas as pd
import os

print("Begin")

# class for callbacks - This class is to allow the output of each node to be 
# safely combined
class Sum:
    def __init__(self):
        self.value = 0.0
        self.lock = _thread.allocate_lock()
        self.count = 0

    #the callback function
    def add(self, value):
        # we must use lock here because += is not atomic
        self.count += 1
        self.lock.acquire()
        self.value += value
        self.lock.release()

# This is the function that is sent to each node for independent analysis
def part_sum(start, end):
    """Calculates partial sum"""
    sum = 0
    for x in range(int(start), int(end)):
        if int(x) % 2 == 0:
           sum -= 1.0 / x
        else:
           sum += 1.0 / x
    return sum

# Control script - run by the master to control the analysis and each of the 
# nodes
print("""Usage: python callback.py [ncpus]
    [ncpus] - the number of workers to run in parallel, 
    if omitted it will be set to the number of processors in the system
    """)

start = 1
end = 200000000

# Divide the task into 128 subtasks
parts = 128
step = (end - start) / parts + 1

# tuple of all parallel python servers to connect with
ppservers = ("*:35000",) #find all available servers listening on port 35000!!!

if len(sys.argv) > 1:
    ncpus = int(sys.argv[1])

    # Creates jobserver with ncpus workers
    job_server = pp.Server(ncpus, ppservers=ppservers)
    print("Starting pp with", ncpus, "workers")
else:
    # Creates jobserver with automatically detected number of workers
    # also uses 2 local cpus!
    job_server = pp.Server(ppservers=ppservers,secret="secretword")
    #ncpus = job_server.get_ncpus() - 2
    print("Starting pp with auto discovery")

# Create an instance of callback class
sum = Sum()

# Execute the same task with different amount of active workers and measure the time
start_time = time.time()
for index in range(parts):
    starti = int(start+index*step)
    endi = int(min(start+(index+1)*step, end))
    # Submit a job which will calculate partial sum 
    # part_sum - the function
    # (starti, endi) - tuple with arguments for part_sum
    # callback=sum.add - callback function

    job_server.submit(part_sum, (starti, endi), callback=sum.add)

#wait for jobs in all groups to finish 
job_server.wait()

# Print the partial sum
print("Partial sum is", sum.value, "| diff =", math.log(2) - sum.value)

job_server.print_stats()

print("Done")
# Parallel Python Software: http://www.parallelpython.com
所有计算机都运行Windows 10,并且具有相同版本的Python和使用的软件包。批处理脚本正在运行。这些计算机都在同一个网络上。我没有看到所有节点的可能原因是什么


谢谢

我遇到的问题是无法连接的计算机正在运行VirtualBox。我卸载了此程序,发现计算机没有问题。

可能未找到的节点启用了软件防火墙,从而阻止了连接?我已尝试更改防火墙设置以允许Python通过,但似乎没有任何区别。此外,正在连接的计算机具有相同的防火墙,我没有更改这些防火墙上的任何设置。