Made MPI magic Linux compat.

This commit is contained in:
Martin Lilleeng Sætra 2019-08-06 11:18:04 +00:00
parent d605b9e102
commit 75678c4fb3
No known key found for this signature in database
GPG Key ID: 5282F74D778CB274
2 changed files with 35 additions and 70 deletions

View File

@ -232,10 +232,7 @@ class PopenFileBuffer(object):
self.stderr.seek(0, 2)
return cout, cerr
class IPEngine(object):
"""
Class for starting IPEngines for MPI processing in IPython
@ -247,11 +244,13 @@ class IPEngine(object):
self.logger.info("Starting IPController")
self.c_buff = PopenFileBuffer()
c_cmd = ["ipcontroller", "--ip='*'"]
self.c = subprocess.Popen(c_cmd,
stderr=self.c_buff.stderr,
stdout=self.c_buff.stdout,
shell=False,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
c_params = dict()
c_params['stderr'] = self.c_buff.stderr
c_params['stdout'] = self.c_buff.stdout
c_params['shell'] = False
if os.name == 'nt':
c_params['creationflags'] = subprocess.CREATE_NEW_PROCESS_GROUP
self.c = subprocess.Popen(c_cmd, **c_params)
#Wait until controller is running
time.sleep(3)
@ -260,11 +259,13 @@ class IPEngine(object):
self.logger.info("Starting IPEngines")
self.e_buff = PopenFileBuffer()
e_cmd = ["mpiexec", "-n", str(n_engines), "ipengine", "--mpi"]
self.e = subprocess.Popen(e_cmd,
stderr=self.e_buff.stderr,
stdout=self.e_buff.stdout,
shell=False,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
e_params = dict()
e_params['stderr'] = self.e_buff.stderr
e_params['stdout'] = self.e_buff.stdout
e_params['shell'] = False
if os.name == 'nt':
e_params['creationflags'] = subprocess.CREATE_NEW_PROCESS_GROUP
self.e = subprocess.Popen(e_cmd, **e_params)
# attach to a running cluster
import ipyparallel

View File

@ -67,12 +67,13 @@
"text": [
"Console logger using level INFO\n",
"File logger using level DEBUG to mpi.log\n",
"Python version 3.6.7 |Anaconda custom (64-bit)| (default, Oct 28 2018, 19:44:12) [MSC v.1915 64 bit (AMD64)]\n"
"Python version 3.7.2 (default, Mar 13 2019, 14:18:46) \n",
"[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]\n"
]
}
],
"source": [
"%setup_logging --out mpi.log"
"%setup_logging --out mpi.log my_logger"
]
},
{
@ -93,7 +94,6 @@
"Waiting for cluster...\n",
"Waiting for cluster...\n",
"Waiting for cluster...\n",
"Waiting for cluster...\n",
"Done\n"
]
}
@ -126,21 +126,19 @@
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[stderr:0] \n",
"Console logger using level INFO\n",
"File logger using level DEBUG to mpi_0.log\n",
"Python version 3.6.7 |Anaconda custom (64-bit)| (default, Oct 28 2018, 19:44:12) [MSC v.1915 64 bit (AMD64)]\n",
"[stderr:1] \n",
"Console logger using level INFO\n",
"File logger using level DEBUG to mpi_1.log\n",
"Python version 3.6.7 |Anaconda custom (64-bit)| (default, Oct 28 2018, 19:44:12) [MSC v.1915 64 bit (AMD64)]\n",
"[stderr:2] \n",
"Console logger using level INFO\n",
"File logger using level DEBUG to mpi_2.log\n",
"Python version 3.6.7 |Anaconda custom (64-bit)| (default, Oct 28 2018, 19:44:12) [MSC v.1915 64 bit (AMD64)]\n"
"ename": "CompositeError",
"evalue": "one or more exceptions from call to method: execute\n[0:execute]: UsageError: the following arguments are required: name\n[1:execute]: UsageError: the following arguments are required: name\n[2:execute]: UsageError: the following arguments are required: name",
"output_type": "error",
"traceback": [
"[0:execute]: ",
"No traceback available",
"",
"[1:execute]: ",
"No traceback available",
"",
"[2:execute]: ",
"No traceback available",
""
]
}
],
@ -153,44 +151,10 @@
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[stderr:0] \n",
"Registering my_context in user workspace\n",
"PyCUDA version 2018.1.1\n",
"CUDA version (10, 0, 0)\n",
"Driver version 10000\n",
"Using 'GeForce 840M' GPU\n",
"Created context handle <661683335040>\n",
"Using CUDA cache dir c:\\Users\\anbro\\Documents\\projects\\GPUSimulators\\GPUSimulators\\cuda_cache\n",
"Autotuning enabled. It may take several minutes to run the code the first time: have patience\n",
"[stderr:1] \n",
"Registering my_context in user workspace\n",
"PyCUDA version 2018.1.1\n",
"CUDA version (10, 0, 0)\n",
"Driver version 10000\n",
"Using 'GeForce 840M' GPU\n",
"Created context handle <45756126480>\n",
"Using CUDA cache dir c:\\Users\\anbro\\Documents\\projects\\GPUSimulators\\GPUSimulators\\cuda_cache\n",
"Autotuning enabled. It may take several minutes to run the code the first time: have patience\n",
"[stderr:2] \n",
"Registering my_context in user workspace\n",
"PyCUDA version 2018.1.1\n",
"CUDA version (10, 0, 0)\n",
"Driver version 10000\n",
"Using 'GeForce 840M' GPU\n",
"Created context handle <632867223392>\n",
"Using CUDA cache dir c:\\Users\\anbro\\Documents\\projects\\GPUSimulators\\GPUSimulators\\cuda_cache\n",
"Autotuning enabled. It may take several minutes to run the code the first time: have patience\n"
]
}
],
"outputs": [],
"source": [
"%%px\n",
"%cuda_context_handler my_context"
"%cuda_context_handler -na my_context"
]
},
{
@ -692,7 +656,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python [default]",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
@ -706,7 +670,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.7.2"
}
},
"nbformat": 4,