<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Shasha,<div class=""><br class=""></div><div class=""> ChimeraX does not use CUDA. It only uses the graphics card with OpenGL for graphics rendering, not for non-graphical calculations. There is one exception to that, the ISOLDE plugin to ChimeraX can use CUDA if you tell it to.</div><div class=""><br class=""></div><div class=""> So I think the environment variable you would need to use is NVIDIA_VISIBLE_DEVICES. I don't know why that would not work. ChimeraX is using Qt to create a QOpenGLContext(). That Python code is in your distribution in file</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>chimera/lib/python3.7/site-packages/chimerax/graphics/opengl.py</div><div class=""><br class=""></div><div class=""><div class=""> # Create context</div><div class=""> from PyQt5.QtGui import QOpenGLContext</div><div class=""> qc = QOpenGLContext()</div><div class=""> qc.setScreen(self._screen)</div><div class=""><br class=""></div><div class="">The Qt window toolkit has no capabilities to choose the GPU as far as I know. I don't have a multi-GPU nvidia system to test on, but I tried starting ChimeraX from a bash shell with</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>NVIDIA_VISIBLE_DEVICES=1 chimerax</div><div class=""><br class=""></div><div class="">and put in code to print the environment variables before the QOpenGLContext is created and the environment is printed and set. I was worried that ChimeraX might remove some environment variables but that does not happen. So I cannot explain why the environment variable does not work.</div><div class=""><br class=""></div><div class=""> I know nothing about Nvidia-SMI but am surprised that it can choose between different graphics cards while rendering to the same screen. I am more familiar with macOS with an external GPU and two displays. With that operating system if I run ChimeraX on the iMac and MacBook laptop display it uses the computer's graphics, and if I run ChimeraX on an external display attached to the external GPU it runs it using the external GPU -- in other words the display you run on controls which GPU is used. In fact, on macOS it remarkably switches which GPU is being used if I simply drag the ChimeraX window from one display to the other. Of course Ubuntu is entirely different and it seems like NVIDIA_VISIBLE_DEVICES=1 should work.</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>Tom</div><div class=""><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 24, 2020, at 9:21 AM, Shasha Feng <<a href="mailto:shaalltime@gmail.com" class="">shaalltime@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class="">Hi Guillaume, and Eric<div class=""><br class=""></div><div class="">Thanks for the tip. The temporary assignment of visiable GPU devices is exactly what I want to get. Though it looks like the recipe of using 'CUDA_VISIBLE_DEVICES=1' does not work at least on my ubuntu 20.04 with chimerax 1.0. I also tried Eric's suggestion just now. </div><div class=""><br class=""></div><div class=""><font face="monospace" class="">sf@sf-MS-7C35:~$ echo $CUDA_VISIBLE_DEVICES<br class=""><br class="">sf@sf-MS-7C35:~$ export CUDA_VISIBLE_DEVICES=1<br class="">sf@sf-MS-7C35:~$ echo $CUDA_VISIBLE_DEVICES<br class="">1<br class="">sf@sf-MS-7C35:~$ chimerax &<br class="">[1] 673010<br class="">sf@sf-MS-7C35:~$ nvidia-smi<br class="">Tue Nov 24 12:09:28 2020 <br class="">+-----------------------------------------------------------------------------+<br class="">| NVIDIA-SMI 450.66 Driver Version: 450.66 CUDA Version: 11.0 |<br class="">|-------------------------------+----------------------+----------------------+<br class="">| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |<br class="">| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |<br class="">| | | MIG M. |<br class="">|===============================+======================+======================|<br class="">| 0 GeForce RTX 207... Off | 00000000:2D:00.0 On | N/A |<br class="">| 60% 74C P2 191W / 215W | 763MiB / 7974MiB | 99% Default |<br class="">| | | N/A |<br class="">+-------------------------------+----------------------+----------------------+<br class="">| 1 GeForce RTX 207... Off | 00000000:2E:00.0 Off | N/A |<br class="">| 0% 34C P8 14W / 215W | 14MiB / 7982MiB | 0% Default |<br class="">| | | N/A |<br class="">+-------------------------------+----------------------+----------------------+<br class=""> <br class="">+-----------------------------------------------------------------------------+<br class="">| Processes: |<br class="">| GPU GI CI PID Type Process name GPU Memory |<br class="">| ID ID Usage |<br class="">|=============================================================================|<br class="">| 0 N/A N/A 1343 G /usr/lib/xorg/Xorg 35MiB |<br class="">| 0 N/A N/A 2338 G /usr/lib/xorg/Xorg 174MiB |<br class="">| 0 N/A N/A 2463 G /usr/bin/gnome-shell 233MiB |<br class="">| 0 N/A N/A 671633 G ...AAAAAAAAA= --shared-files 45MiB |<br class="">| 0 N/A N/A 672504 C /opt/conda/bin/python 229MiB |<br class="">| 0 N/A N/A 673010 G chimerax 33MiB |<br class="">| 1 N/A N/A 1343 G /usr/lib/xorg/Xorg 4MiB |<br class="">| 1 N/A N/A 2338 G /usr/lib/xorg/Xorg 4MiB |<br class="">+-----------------------------------------------------------------------------+</font><br class=""></div><div class=""><font face="monospace" class=""><br class=""></font></div><div class=""><font face="arial, sans-serif" class="">After setting the environment variable and running chimerax in the same session, it still runs on GPU 0. </font></div><div class=""><font face="arial, sans-serif" class="">I also tried a recipe that defines </font></div><div class=""><font face="arial, sans-serif" class="">"export NVIDIA_VISIBLE_DEVICES=1,</font></div><div class=""><font face="arial, sans-serif" class="">export CUDA_VISIBLE_DEVICES=0" shared here [</font><a href="https://stackoverflow.com/a/58445444" class="">https://stackoverflow.com/a/58445444</a><span style="font-family:arial,sans-serif" class="">]. </span><span style="font-family:arial,sans-serif" class="">It does not work either. </span></div><div class=""><span style="font-family:arial,sans-serif" class=""><br class=""></span></div><div class=""><span style="font-family:arial,sans-serif" class="">To ChimeraX developers,</span></div><div class=""><span style="font-family:arial,sans-serif" class="">I wonder how ChimeraX is exposed to CUDA. I have basis in CUDA computing and using CUDA in Python. If you can give some clues, that would be great.</span></div><div class=""><span style="font-family:arial,sans-serif" class=""><br class=""></span></div><div class=""><span style="font-family:arial,sans-serif" class="">Best,</span></div><div class=""><span style="font-family:arial,sans-serif" class="">Shasha</span></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 24, 2020 at 12:18 PM Eric Pettersen <<a href="mailto:pett@cgl.ucsf.edu" class="">pett@cgl.ucsf.edu</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class="">To supplement Guilaume's very helpful answer, you could make an alias to reduce the typing involved, and you could put the alias in your shell startup file. For the bash shell, the syntax for making an alias named 'cx' for the command would be:<div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class=""> </span>alias cx="CUDA_VISIBLE_DEVICES=1 chimerax"</div><div class=""><br class=""></div><div class="">Other shells have similar (but not necessarily identical) syntaxes.</div><div class=""><br class=""></div><div class=""><div class="">--Eric</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class=""> </span>Eric Pettersen</div><div class=""><span style="white-space:pre-wrap" class=""> </span>UCSF Computer Graphics Lab</div><div class=""><br class=""></div><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Nov 24, 2020, at 12:09 AM, Guillaume Gaullier <<a href="mailto:guillaume@gaullier.org" target="_blank" class="">guillaume@gaullier.org</a>> wrote:</div><br class=""><div class=""><div style="overflow-wrap: break-word;" class=""><div class="">Hello,</div><div class=""><br class=""></div>You can restrict which of your GPUs ChimeraX will be able to detect by starting it from the shell like so:<div class=""><br class=""></div><div class="">CUDA_VISIBLE_DEVICES=1 chimerax</div><div class=""><br class=""></div><div class="">replace 1 with the device number you want, this is the same one as reported by nvidia-smi. This will work until you close ChimeraX, next time you run it you still need to add the environment variable before the "chimerax" command.</div><div class=""><div class=""><br class=""></div><div class="">You can also make this environment variable stay around until you close the shell session like so:</div><div class=""><br class=""></div><div class="">export CUDA_VISIBLE_DEVICES=1</div><div class=""><br class=""></div><div class="">then you can open ChimeraX from the same shell session, close it, and reopen with only the "chimerax" command and it should still only see the GPU you indicated.</div><div class=""><br class=""></div><div class="">When you close and restart your shell, you will have to export the environment variable again. I don’t recommend adding the export to your ~/.bashrc or other shell initialization script, because then all your shell sessions will have this environment variable set, so all the commands you run will only see this GPU, which is probably not what you want. It is less likely to get in your way down the road if you only set this environment variable for the duration of a shell you opened specifically to run ChimeraX from.</div><div class=""><br class=""></div><div class="">I hope this helps,</div><div class="">
<div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none" class=""><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none" class=""><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none" class=""><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none" class=""><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none" class=""><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div style="overflow-wrap: break-word;" class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class="">Guillaume</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div></div></div></div></div></div></div></div></div></div>
</div>
<div class=""><br class=""><blockquote type="cite" class=""><div class="">On 24 Nov 2020, at 01:51, Shasha Feng <<a href="mailto:shaalltime@gmail.com" target="_blank" class="">shaalltime@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class="">Hi Tom,<div class=""><br class=""></div><div class="">Sorry about not clarifying my operating system. I am using ubuntu 20.04 with two NVIDIA GPU cards. </div><div class="">Do I need to change OpenGL setting or reconfigure the nvidia setting? </div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Shasha</div><div class=""><br class=""></div><div class=""><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 23, 2020 at 6:58 PM Tom Goddard <<a href="mailto:goddard@sonic.net" target="_blank" class="">goddard@sonic.net</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="">Hi Shasta,</div><div class=""><br class=""></div>ChimeraX has no way to select which GPU it uses. The operating system or opengl driver decides. You didn't mention which operating system you are using. Here is an example of how to set the default OpenGL GPU in Windows.<div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class=""> </span><a href="https://www.techadvisor.co.uk/how-to/pc-components/how-set-default-graphics-card-3612668/" target="_blank" class="">https://www.techadvisor.co.uk/how-to/pc-components/how-set-default-graphics-card-3612668/</a></div><div class=""><br class=""></div><div class=""> Tom</div><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Nov 23, 2020, at 2:38 PM, Shasha Feng <<a href="mailto:shaalltime@gmail.com" target="_blank" class="">shaalltime@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="">Hi,</div><div class=""><br class=""></div><div class="">Is there any way to specify which GPU device for ChimeraX to run on? Currently, it uses the default GPU 0, which can disturb the existing jobs. Thanks.</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Shasha</div><div class=""><br class=""></div></div>
_______________________________________________<br class="">ChimeraX-users mailing list<br class=""><a href="mailto:ChimeraX-users@cgl.ucsf.edu" target="_blank" class="">ChimeraX-users@cgl.ucsf.edu</a><br class="">Manage subscription:<br class=""><a href="https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users" target="_blank" class="">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><div class=""><br class=""></div></div>
_______________________________________________<br class="">ChimeraX-users mailing list<br class=""><a href="mailto:ChimeraX-users@cgl.ucsf.edu" target="_blank" class="">ChimeraX-users@cgl.ucsf.edu</a><br class="">Manage subscription:<br class=""><a href="https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users" target="_blank" class="">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">ChimeraX-users mailing list<br class=""><a href="mailto:ChimeraX-users@cgl.ucsf.edu" target="_blank" class="">ChimeraX-users@cgl.ucsf.edu</a><br class="">Manage subscription:<br class=""><a href="https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users" target="_blank" class="">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><div class=""><br class=""></div></div>
_______________________________________________<br class="">ChimeraX-users mailing list<br class=""><a href="mailto:ChimeraX-users@cgl.ucsf.edu" class="">ChimeraX-users@cgl.ucsf.edu</a><br class="">Manage subscription:<br class="">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users<br class=""></div></blockquote></div><br class=""></div></body></html>