#10398 closed enhancement (fixed)
Add OpenMM platform option to tug command
Reported by: | Tom Goddard | Owned by: | Tom Goddard |
---|---|---|---|
Priority: | moderate | Milestone: | |
Component: | MD/Ensemble Analysis | Version: | |
Keywords: | Cc: | Elaine Meng | |
Blocked By: | Blocking: | ||
Notify when closed: | Platform: | all | |
Project: | ChimeraX |
Description
Would be nice to add a platform option to the tug command to use Metal, OpenMM or CPU computation. Currently it is hard-coded to use CPU which is 10x slower than OpenCL and 12x slower than Metal in my tests today.
ISOLDE 1.6 benchmark, small cryoEM 4913 atoms
CPU 0.99 sec per coord update, HIP 0.083 sec/update, OpenCL 0.103 sec/update
ISOLDE 1.7 benchmark, small cryoEM 4913 atoms
CPU 1.01 sec per coord update, HIP 0.082 sec/update, OpenCL 0.103 sec/update
Change History (11)
comment:1 by , 22 months ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:2 by , 22 months ago
The tug and minimize mouse modes have not way of controlling the OpenMM platform. Would be nice to add a mouse mode setting for that since it can make a 10x difference in speed.
comment:3 by , 22 months ago
It might be useful (if possible) to report what platform is being used. On my M1 Mac laptop I could use CPU, OpenCL, HIP or unspecified, but don't know which one I get when it's not specified.
Also, trying to specify "platform CUDA" even though I know it's not available gives a traceback:
Log contents:
tug #1:5-9@ca toAtoms #2/A:4-8@ca platform CPU
tug #1:5-9@ca toAtoms #2/A:4-8@ca platform OpenCL
tug #1:8-12@ca toAtoms #2/A:4-8@ca platform HIP
tug #1:8-12@ca toAtoms #2/A:4-8@ca platform CUDA
Traceback (most recent call last):
File "/Users/meng/Desktop/ChimeraX_Daily.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/cmd_line/tool.py", line 319, in execute
cmd.run(cmd_text)
File "/Users/meng/Desktop/ChimeraX_Daily.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/core/commands/cli.py", line 2908, in run
result = ci.function(session, kw_args)
File "/Users/meng/Desktop/ChimeraX_Daily.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/tug/tugcommand.py", line 64, in tug
tugger = StructureTugger(us[0], force_constant = force_constant,
File "/Users/meng/Desktop/ChimeraX_Daily.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/tug/tugatoms.py", line 259, in init
self._create_openmm_system()
File "/Users/meng/Desktop/ChimeraX_Daily.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chimerax/tug/tugatoms.py", line 448, in _create_openmm_system
platform = mm.Platform.getPlatformByName(self._platform_name)
File "/Users/meng/Desktop/ChimeraX_Daily.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/openmm/openmm.py", line 18655, in getPlatformByName
return _openmm.Platform_getPlatformByName(name)
openmm.OpenMMException: There is no registered Platform called "CUDA"
openmm.OpenMMException: There is no registered Platform called "CUDA"
File "/Users/meng/Desktop/ChimeraX_Daily.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/openmm/openmm.py", line 18655, in getPlatformByName
return _openmm.Platform_getPlatformByName(name)
comment:4 by , 22 months ago
Also possibly useful but maybe not feasible, a way to query which platforms are available on the system being used. I guess the tug command essentially serves this purpose, but requires trying each choice in a separate command.
comment:5 by , 22 months ago
In comment 3, do you (Elaine) mean whenever the tug command is run it should log a message saying what platform is being used? That seems odd. The platform has a default value as I say in comment 1 (CPU on windows/linux, OpenCL on Mac) and it isn't too common that we echo the default values being used for a command. And this one seems rather technical and obscure.
Regarding comment 4, I agree it would be handy if a command like "tug listplatforms" could list the available platforms. But it seems pretty unimportant unless OpenMM starts introducing new platforms. Otherwise just listing CUDA, OpenCL, HIP, CPU in the docs seems sufficient. A new command could check which of those are actually available on the computer. But given how trivial it is for the user simply to try the one they want and see if it works, I'm not too excited to go to the work of making a convenience command that would be used by almost no one.
If the user is on Windows or Linux the default is CPU and if they have Nvidia graphics with CUDA installed it would run 10-100 times faster using CUDA. It would make sense for the code to by default use CUDA if available, otherwise OpenCL, otherwise CPU on all platforms. I've made a separate ticket for that #10431. That would be especially helpful if the tug mouse mode did the same since currently the user has no way to get the CUDA platform for the mouse mode where it would make a big difference.
comment:6 by , 22 months ago
Hi Tom,
When there is a single default like for most command options, we can document it and there is no need to inform the user. However, in this case, the user cannot tell what the default is because it depends on their system and most users (like me) aren't hardware-savvy enough to know, even though it's obvious to someone like you. So some way for us relatively ignorant users of finding out (whether "tug" command automatically logs it or some other way, no strong opinion on that) would be useful.
Elaine
comment:7 by , 22 months ago
I think users are savvy enough to know whether they have a Mac or Windows or Linux computer. But I think your suggestion has led to the idea for a much more valuable improvement -- that is have the code choose the fastest platform by default. That is ticket #10431. If that is done it would make sense to report which platform it chose because the fastest, CUDA, often is finicky to install and doesn't work and a user will want to know if they got CUDA to work.
comment:8 by , 22 months ago
I don't mean mac vs windows vs linux! I meant what is computing the openmm stuff, as set by the "platform" option.
comment:9 by , 22 months ago
If the user wants to know what the default openmm platform is they look at the documentation and it says the default platform is CPU on Windows and Linux and OpenCL on Mac. I don't understand why that seems problematic to you. Almost no users will even be aware that OpenMM supports different "platforms" and what that means, and what the possibilities are. So the user would have to go to the documentation in any case to learn about this, and the default is very easy to explain. I must be missing something.
comment:10 by , 22 months ago
I didn't know that CPU is default on windows and OpenCL is default on mac. If you told me that, apologies, I missed it. The documentation I wrote doesn't say it yet. Example: I didn't know what "tug" was using even though I know I'm on a mac m1 laptop. Beats me whether it was CPU, or HIP, or OpenCL. I can read that CUDA is only on windows or linux, so I know it's not that one.
comment:11 by , 22 months ago
Aha! That explains the misunderstanding. In comment 1 of this ticket I say
"The default platform used to be CPU on all operating systems. I've changed it to use OpenCL on Mac, and CPU on Windows and Linux."
Done in daily builds.
The values of the platform option depend on what operating system you are running. Possibilities are CPU, OpenCL, CUDA, HIP. CUDA will only be available on Windows or Linux systems with an Nvidia graphics driver and CUDA installed. OpenCL is available on Mac and may be a choice on Windows or Linux. HIP is supposed to be for AMD graphics support, but ChimeraX does not have those AMD libraries and instead HIP invokes the Mac Metal libraries.
The default platform used to be CPU on all operating systems. I've changed it to use OpenCL on Mac, and CPU on Windows and Linux.