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
2 changed files with 35 additions and 70 deletions

View File

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

View File

@@ -67,12 +67,13 @@
"text": [ "text": [
"Console logger using level INFO\n", "Console logger using level INFO\n",
"File logger using level DEBUG to mpi.log\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": [ "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",
"Waiting for cluster...\n", "Waiting for cluster...\n",
"Waiting for cluster...\n",
"Done\n" "Done\n"
] ]
} }
@@ -126,21 +126,19 @@
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stderr", "ename": "CompositeError",
"output_type": "stream", "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",
"text": [ "output_type": "error",
"[stderr:0] \n", "traceback": [
"Console logger using level INFO\n", "[0:execute]: ",
"File logger using level DEBUG to mpi_0.log\n", "No traceback available",
"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", "[1:execute]: ",
"Console logger using level INFO\n", "No traceback available",
"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", "[2:execute]: ",
"[stderr:2] \n", "No traceback available",
"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"
] ]
} }
], ],
@@ -153,44 +151,10 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [ "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"
]
}
],
"source": [ "source": [
"%%px\n", "%%px\n",
"%cuda_context_handler my_context" "%cuda_context_handler -na my_context"
] ]
}, },
{ {
@@ -692,7 +656,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python [default]", "display_name": "Python 3",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@@ -706,7 +670,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.7" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,