ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
431 stars 121 forks source link

Getting started with pyansys - mapdl = launch_mapdl() stalls #574

Closed mcMunich closed 3 years ago

mcMunich commented 3 years ago

Trying to launch mapdl from my spyder editor. But the problem is reproducible in a cmd prompt.

After a while it times out apparently and the cmd prompt shows the following:

Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

from ansys.mapdl.core import launch_mapdl mapdl = launch_mapdl(exec_file='C:\Program Files\ANSYS Inc\v212\ansys\bin\winx64\ansys212.exe', loglevel='ERROR') Traceback (most recent call last): File "", line 1, in NameError: name 'launch_mapdl' is not defined from ansys.mapdl.core import launch_mapdl mapdl = launch_mapdl(exec_file='C:\Program Files\ANSYS Inc\v212\ansys\bin\winx64\ansys212.exe', loglevel='ERROR') Traceback (most recent call last): File "", line 1, in File "C:\Users\mcapella\AppData\Local\Programs\Python\Python38\lib\site-packages\ansys\mapdl\core\launcher.py", line 933, in launch_mapdl mapdl = MapdlGrpc(ip=LOCALHOST, port=port, File "C:\Users\mcapella\AppData\Local\Programs\Python\Python38\lib\site-packages\ansys\mapdl\core\mapdl_grpc.py", line 230, in init raise IOError('Unable to connect to MAPDL gRPC instance at %s' % OSError: Unable to connect to MAPDL gRPC instance at 127.0.0.1:50052

mcMunich commented 3 years ago

spyder returns similar, an error message about the gRPC instance: mapdl = launch_mapdl() Traceback (most recent call last):

File "", line 1, in mapdl = launch_mapdl()

File "C:\ProgramData\Anaconda3\lib\site-packages\ansys\mapdl\core\launcher.py", line 926, in launch_mapdl mapdl = MapdlGrpc(ip=LOCALHOST, port=port,

File "C:\ProgramData\Anaconda3\lib\site-packages\ansys\mapdl\core\mapdl_grpc.py", line 224, in init raise IOError('Unable to connect to MAPDL gRPC instance at %s' %

OSError: Unable to connect to MAPDL gRPC instance at 127.0.0.1:50057

akaszynski commented 3 years ago

Thanks for posting here.

Try the following to debug:

from ansys.mapdl import core as pymapdl
mapdl = pymapdl.launch_mapdl(verbose_mapdl=True, additional_switches='-smp')

Verbose will printout the command used and -smp will use shared memory parallel (helps with license issues sometimes).

Take a look at output and if it looks correct, try running the same command pymapdl used in a separate command prompt. Quite likely, MAPDL isn't starting for some reason.

mcMunich commented 3 years ago

import ansys.mapdl as core pymapdl SyntaxError: invalid syntax

I think there is something missing in the first line.

akaszynski commented 3 years ago

Sorry! This is what I get for multi tasking. Edited and should read:

from ansys.mapdl import core as pymapdl
mcMunich commented 3 years ago

The smp solution seems to have been the issue. When I use it in my normal call I can proceed.

from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(verbose_mapdl=True, additional_switches='-smp')
print(mapdl)
Running "C:\Program Files\ANSYS Inc\v212\ansys\bin\winx64\ansys212.exe" -j file -np 2  -b -i .__tmp__.inp -o .__tmp__.out -smp -port 50056 -grpc
Product:             Ansys Mechanical Enterprise
MAPDL Version:       RELEASE  2021 R2           BUILD 21.2      UPDATE 20210601
ansys.mapdl Version: 0.58.6
akaszynski commented 3 years ago

Ah, you're using 2021R2. Ok, DMP is a known issue here on windows and we're looking into this right now. I'll create a hotfix to warn the user that this is failing to launch on 2021R2 and to force SMP for the time being.

akaszynski commented 3 years ago

We've investigated this locally as as far as we can tell, this is directly related to licencing and the VPN. DMP works without any issues when the license server is on the same network as the MAPDL server.

sa-cross commented 3 years ago

@akaszynski @germa89 Had to ask a few people on this one. Workaround for VPN with MAPDL post v211 is to use MSMPI on Windows platform

So to the MAPDL command line add -mpi msmpi

akaszynski commented 3 years ago

Thanks @sa-cross, that's super helpful. Should we make this a default option on Windows?

sa-cross commented 3 years ago

Yes I would for the 2021 Rx versions specifically.

germa89 commented 3 years ago

Closing this issue has the required changed have been implemented and they will go public in 0.60 release.