我有一个使用该Parallel::ForkManager
模块分叉的Perl脚本.
据我所知,如果我分叉32个子进程并要求SLURM调度程序在4个节点上运行作业,每个节点有8个处理器,则代码将在每个核心上执行每个子进程.
我实验室的某个人说,如果我在多个节点上运行一个工作,那么其他节点就不会被使用,而且我在浪费时间和金钱.这准确吗?
如果我使用的是一个脚本,我只能使用SLURM限制一个节点?
我将python 2.7与multiprocessing :: Pool一起使用以并行运行作业
我简化了下面的示例,但这是它的主要要旨。
它将使用该apply_async()
函数为我的字典中的每个人创建一个文件。但是,当我检查文件是否正确创建时,我注意到有时文件没有创建。
现在我想我在使用multiprocessing :: Pool的方式上做错了
有什么建议吗?
import os
from multiprocessing import Pool
def outputFile(person):
ofh=open(person+'.txt','w')
ofh.write('test\n')
ofh.close()
pool = Pool(processes=4)
for person in person_dict:
pool.apply_async(outputFile,args(person))
pool.close()
pool.join()
for person in person_dict:
print os.path.isfile(person+'.txt')
Run Code Online (Sandbox Code Playgroud)
True
True
False
True
Run Code Online (Sandbox Code Playgroud) 我有一个熊猫数据框和一个一维的numpy nd数组。实际上,这是一个列表。
如何使用数组中的值向DataFrame添加新列?
test['preds'] = preds
给出SettingWithCopyWarning
警告:
试图在DataFrame的切片副本上设置一个值。尝试改用.loc [row_indexer,col_indexer] = value
当我尝试pd.DataFrame({test,preds})
,我得到TypeError: unhashable type: 'list'
这是我的代码
sample_fh = dir + "sampleManifest.txt"
kids = {}
fid = {}
parents = {}
status = {}
sex = {}
with open(sample_fh) as f:
for line in f:
line = line.rstrip('\n')
row = line.split('\t')
fid = row[0]
iid = row[1]
relation = row[5]
status = row[6]
sex = row[7]
if relation != "Mother" and relation != "Father":
kids[iid] = 1
status[iid] = status
fid[iid] = fid
sex[iid]= row[7]
if relation == "Mother" or relation == "Father":
parents[(fid,relation)] = iid …
Run Code Online (Sandbox Code Playgroud)