Skip to content

Instantly share code, notes, and snippets.

@jaimergp
Last active April 22, 2021 16:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jaimergp/45015e75b4ae5f79a03d24e53b74ac1a to your computer and use it in GitHub Desktop.
Save jaimergp/45015e75b4ae5f79a03d24e53b74ac1a to your computer and use it in GitHub Desktop.
Using OpenMMTools in Google Colab
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "gPFd5CO2yosb"
},
"source": [
"# Install Miniconda\n",
"It's the normal procedure, but:\n",
"- We stick to v4.5.4 because it ships with Python 3.6 (same as Google Colab runtime) for compatibility.\n",
"- We install it in `/usr/local`\n",
"\n",
"__Note 1__: If you want to use GPU acceleration, enable it now (before installing anything). Otherwise you will have to repeat everything after enabling GPU acceleration.\n",
"\n",
"__Note 2__: Solving dependencies in such a convoluted environment (`/usr/lib`) can (sometimes) take _a while_ (20 mins in my last attempt). It might be a better idea to use `constructor` ([check here](https://github.com/conda/constructor)) to prebuild a conda installation with all the packages you want if you intend to use them quite often.\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1475
},
"colab_type": "code",
"id": "xXGOv9XLO5UL",
"outputId": "d663f0ec-19ec-47d8-8141-c7b3bd7dbae5"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"--2019-04-24 12:38:44-- https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh\n",
"Resolving repo.continuum.io (repo.continuum.io)... 104.18.200.79, 104.18.201.79, 2606:4700::6812:c84f, ...\n",
"Connecting to repo.continuum.io (repo.continuum.io)|104.18.200.79|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 58468498 (56M) [application/x-sh]\n",
"Saving to: ‘Miniconda3-4.5.4-Linux-x86_64.sh’\n",
"\n",
"Miniconda3-4.5.4-Li 100%[===================>] 55.76M 132MB/s in 0.4s \n",
"\n",
"2019-04-24 12:38:45 (132 MB/s) - ‘Miniconda3-4.5.4-Linux-x86_64.sh’ saved [58468498/58468498]\n",
"\n",
"PREFIX=/usr/local\n",
"installing: python-3.6.5-hc3d631a_2 ...\n",
"Python 3.6.5 :: Anaconda, Inc.\n",
"installing: ca-certificates-2018.03.07-0 ...\n",
"installing: conda-env-2.6.0-h36134e3_1 ...\n",
"installing: libgcc-ng-7.2.0-hdf63c60_3 ...\n",
"installing: libstdcxx-ng-7.2.0-hdf63c60_3 ...\n",
"installing: libffi-3.2.1-hd88cf55_4 ...\n",
"installing: ncurses-6.1-hf484d3e_0 ...\n",
"installing: openssl-1.0.2o-h20670df_0 ...\n",
"installing: tk-8.6.7-hc745277_3 ...\n",
"installing: xz-5.2.4-h14c3975_4 ...\n",
"installing: yaml-0.1.7-had09818_2 ...\n",
"installing: zlib-1.2.11-ha838bed_2 ...\n",
"installing: libedit-3.1.20170329-h6b74fdf_2 ...\n",
"installing: readline-7.0-ha6073c6_4 ...\n",
"installing: sqlite-3.23.1-he433501_0 ...\n",
"installing: asn1crypto-0.24.0-py36_0 ...\n",
"installing: certifi-2018.4.16-py36_0 ...\n",
"installing: chardet-3.0.4-py36h0f667ec_1 ...\n",
"installing: idna-2.6-py36h82fb2a8_1 ...\n",
"installing: pycosat-0.6.3-py36h0a5515d_0 ...\n",
"installing: pycparser-2.18-py36hf9f622e_1 ...\n",
"installing: pysocks-1.6.8-py36_0 ...\n",
"installing: ruamel_yaml-0.15.37-py36h14c3975_2 ...\n",
"installing: six-1.11.0-py36h372c433_1 ...\n",
"installing: cffi-1.11.5-py36h9745a5d_0 ...\n",
"installing: setuptools-39.2.0-py36_0 ...\n",
"installing: cryptography-2.2.2-py36h14c3975_0 ...\n",
"installing: wheel-0.31.1-py36_0 ...\n",
"installing: pip-10.0.1-py36_0 ...\n",
"installing: pyopenssl-18.0.0-py36_0 ...\n",
"installing: urllib3-1.22-py36hbe7ace6_0 ...\n",
"installing: requests-2.18.4-py36he2e5f8d_1 ...\n",
"installing: conda-4.5.4-py36_0 ...\n",
"unlinking: asn1crypto-0.24.0-py37_0\n",
"unlinking: certifi-2018.11.29-py37_0\n",
"unlinking: cffi-1.11.5-py37he75722e_1\n",
"unlinking: chardet-3.0.4-py37_1\n",
"unlinking: conda-4.5.12-py37_0\n",
"unlinking: conda-env-2.6.0-1\n",
"unlinking: cryptography-2.4.2-py37h1ba5d50_0\n",
"unlinking: idna-2.8-py37_0\n",
"unlinking: libgcc-ng-8.2.0-hdf63c60_1\n",
"unlinking: libstdcxx-ng-8.2.0-hdf63c60_1\n",
"unlinking: ncurses-6.1-he6710b0_1\n",
"unlinking: openssl-1.1.1a-h7b6447c_0\n",
"unlinking: pip-18.1-py37_0\n",
"unlinking: pycosat-0.6.3-py37h14c3975_0\n",
"unlinking: pycparser-2.19-py37_0\n",
"unlinking: pyopenssl-18.0.0-py37_0\n",
"unlinking: pysocks-1.6.8-py37_0\n",
"unlinking: python-3.7.1-h0371630_7\n",
"unlinking: readline-7.0-h7b6447c_5\n",
"unlinking: requests-2.21.0-py37_0\n",
"unlinking: ruamel_yaml-0.15.46-py37h14c3975_0\n",
"unlinking: setuptools-40.6.3-py37_0\n",
"unlinking: six-1.12.0-py37_0\n",
"unlinking: sqlite-3.26.0-h7b6447c_0\n",
"unlinking: tk-8.6.8-hbc83047_0\n",
"unlinking: urllib3-1.24.1-py37_0\n",
"unlinking: wheel-0.32.3-py37_0\n",
"unlinking: zlib-1.2.11-h7b6447c_3\n",
"installation finished.\n",
"WARNING:\n",
" You currently have a PYTHONPATH environment variable set. This may cause\n",
" unexpected behavior when running the Python interpreter in Miniconda3.\n",
" For best results, please verify that your PYTHONPATH only points to\n",
" directories of packages that are compatible with the Python interpreter\n",
" in Miniconda3: /usr/local\n"
]
}
],
"source": [
"!wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh && bash Miniconda3-4.5.4-Linux-x86_64.sh -bfp /usr/local"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 2305
},
"colab_type": "code",
"id": "v5DCYIOLEptA",
"outputId": "e10230de-edcc-4d05-bb8f-e8a3741f91ed"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" active environment : None\n",
" user config file : /root/.condarc\n",
" populated config files : \n",
" conda version : 4.5.4\n",
" conda-build version : not installed\n",
" python version : 3.6.5.final.0\n",
" base environment : /usr/local (writable)\n",
" channel URLs : https://repo.anaconda.com/pkgs/main/linux-64\n",
" https://repo.anaconda.com/pkgs/main/noarch\n",
" https://repo.anaconda.com/pkgs/free/linux-64\n",
" https://repo.anaconda.com/pkgs/free/noarch\n",
" https://repo.anaconda.com/pkgs/r/linux-64\n",
" https://repo.anaconda.com/pkgs/r/noarch\n",
" https://repo.anaconda.com/pkgs/pro/linux-64\n",
" https://repo.anaconda.com/pkgs/pro/noarch\n",
" package cache : /usr/local/pkgs\n",
" /root/.conda/pkgs\n",
" envs directories : /usr/local/envs\n",
" /root/.conda/envs\n",
" platform : linux-64\n",
" user-agent : conda/4.5.4 requests/2.18.4 CPython/3.6.5 Linux/4.14.79+ ubuntu/18.04 glibc/2.27\n",
" UID:GID : 0:0\n",
" netrc file : None\n",
" offline mode : False\n",
"\n",
"# conda environments:\n",
"#\n",
"base * /usr/local\n",
"\n",
"sys.version: 3.6.5 |Anaconda, Inc.| (default, Apr 29 ...\n",
"sys.prefix: /usr/local\n",
"sys.executable: /usr/local/bin/python\n",
"conda location: /usr/local/lib/python3.6/site-packages/conda\n",
"conda-build: None\n",
"conda-env: /usr/local/bin/conda-env\n",
"user site dirs: \n",
"\n",
"CIO_TEST: <not set>\n",
"CONDA_ROOT: /usr/local\n",
"LD_LIBRARY_PATH: /usr/lib64-nvidia\n",
"LIBRARY_PATH: /usr/local/cuda/lib64/stubs\n",
"PATH: /usr/local/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin:/opt/bin\n",
"PYTHONPATH: /env/python\n",
"PYTHONWARNINGS: ignore:::pip._internal.cli.base_command\n",
"REQUESTS_CA_BUNDLE: <not set>\n",
"SSL_CERT_FILE: <not set>\n",
"\n",
"\n",
"WARNING: could not import _license.show_info\n",
"# try:\n",
"# $ conda install -n root _license\n",
"# packages in environment at /usr/local:\n",
"#\n",
"# Name Version Build Channel\n",
"asn1crypto 0.24.0 py36_0 \n",
"ca-certificates 2018.03.07 0 \n",
"certifi 2018.4.16 py36_0 \n",
"cffi 1.11.5 py36h9745a5d_0 \n",
"chardet 3.0.4 py36h0f667ec_1 \n",
"conda 4.5.4 py36_0 \n",
"conda-env 2.6.0 h36134e3_1 \n",
"cryptography 2.2.2 py36h14c3975_0 \n",
"idna 2.6 py36h82fb2a8_1 \n",
"libedit 3.1.20170329 h6b74fdf_2 \n",
"libffi 3.2.1 hd88cf55_4 \n",
"libgcc-ng 7.2.0 hdf63c60_3 \n",
"libstdcxx-ng 7.2.0 hdf63c60_3 \n",
"ncurses 6.1 hf484d3e_0 \n",
"openssl 1.0.2o h20670df_0 \n",
"pip 10.0.1 py36_0 \n",
"pycosat 0.6.3 py36h0a5515d_0 \n",
"pycparser 2.18 py36hf9f622e_1 \n",
"pyopenssl 18.0.0 py36_0 \n",
"pysocks 1.6.8 py36_0 \n",
"python 3.6.5 hc3d631a_2 \n",
"readline 7.0 ha6073c6_4 \n",
"requests 2.18.4 py36he2e5f8d_1 \n",
"ruamel_yaml 0.15.37 py36h14c3975_2 \n",
"setuptools 39.2.0 py36_0 \n",
"six 1.11.0 py36h372c433_1 \n",
"sqlite 3.23.1 he433501_0 \n",
"tk 8.6.7 hc745277_3 \n",
"urllib3 1.22 py36hbe7ace6_0 \n",
"wheel 0.31.1 py36_0 \n",
"xz 5.2.4 h14c3975_4 \n",
"yaml 0.1.7 had09818_2 \n",
"zlib 1.2.11 ha838bed_2 \n",
"CLICOLOR=1\n",
"CLOUDSDK_CONFIG=/content/.config\n",
"COLAB_GPU=1\n",
"CUDA_PKG_VERSION=10-0=10.0.130-1\n",
"CUDA_VERSION=10.0.130\n",
"CUDNN_VERSION=7.5.0.56\n",
"DATALAB_SETTINGS_OVERRIDES={\"kernelManagerProxyPort\":6000,\"kernelManagerProxyHost\":\"172.28.0.3\",\"jupyterArgs\":[\"--ip=\\\"172.28.0.2\\\"\"]}\n",
"DEBIAN_FRONTEND=noninteractive\n",
"__EGL_VENDOR_LIBRARY_DIRS=/usr/lib64-nvidia:/usr/share/glvnd/egl_vendor.d/\n",
"ENV=/root/.bashrc\n",
"GCS_READ_CACHE_BLOCK_SIZE_MB=16\n",
"GIT_PAGER=cat\n",
"GLIBCPP_FORCE_NEW=1\n",
"GLIBCXX_FORCE_NEW=1\n",
"HOME=/root\n",
"HOSTNAME=dd67983c307e\n",
"JPY_PARENT_PID=34\n",
"LANG=en_US.UTF-8\n",
"LD_LIBRARY_PATH=/usr/lib64-nvidia\n",
"LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4\n",
"LIBRARY_PATH=/usr/local/cuda/lib64/stubs\n",
"MPLBACKEND=module://ipykernel.pylab.backend_inline\n",
"NCCL_VERSION=2.4.2\n",
"NO_GCE_CHECK=True\n",
"NVIDIA_DRIVER_CAPABILITIES=compute,utility\n",
"NVIDIA_REQUIRE_CUDA=cuda>=10.0 brand=tesla,driver>=384,driver<385 brand=tesla,driver>=410,driver<411\n",
"NVIDIA_VISIBLE_DEVICES=all\n",
"OLDPWD=/\n",
"PAGER=cat\n",
"PATH=/usr/local/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin:/opt/bin\n",
"PWD=/content\n",
"PYTHONPATH=/env/python\n",
"PYTHONWARNINGS=ignore:::pip._internal.cli.base_command\n",
"SHELL=/bin/bash\n",
"SHLVL=2\n",
"TERM=xterm-color\n",
"TF_FORCE_GPU_ALLOW_GROWTH=true\n",
"_=/usr/bin/env\n"
]
}
],
"source": [
"!conda info --all\n",
"!conda list\n",
"!env | sort"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "hD2dcnR7y8Ry"
},
"source": [
"# Install needed packages\n",
"Again the normal procedure, just remember to always use `-y` so `conda` does not wait for confirmation. `-q` is useful to prevent interactive outputs (such as the rolling slash /|\\-/|\\-). Always add `python=3.6` to prevent accidental updates!"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 2933
},
"colab_type": "code",
"id": "3jZucs0Eufuq",
"outputId": "77b61836-52b1-45fe-af18-3623c57efe23"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting package metadata (current_repodata.json): ...working... done\n",
"Solving environment: ...working... done\n",
"\n",
"## Package Plan ##\n",
"\n",
" environment location: /home/jaime/.conda/envs/opencaddtest\n",
"\n",
" added / updated specs:\n",
" - openmm\n",
" - python=3.6\n",
"\n",
"\n",
"The following packages will be downloaded:\n",
"\n",
" package | build\n",
" ---------------------------|-----------------\n",
" cffi-1.14.4 | py36hc120d54_1 225 KB conda-forge\n",
" chardet-4.0.0 | py36h5fab9bb_0 219 KB conda-forge\n",
" cryptography-3.3.1 | py36h0a59100_0 624 KB conda-forge\n",
" importlib-metadata-3.3.0 | py36h5fab9bb_2 20 KB conda-forge\n",
" ipykernel-5.4.2 | py36he448a4c_0 165 KB conda-forge\n",
" ipython-7.12.0 | py36h5ca1d4c_0 1.1 MB conda-forge\n",
" jedi-0.17.2 | py36h5fab9bb_1 957 KB conda-forge\n",
" markupsafe-1.1.1 | py36he6145b8_2 27 KB conda-forge\n",
" mistune-0.8.4 |py36h1d69622_1002 54 KB conda-forge\n",
" notebook-5.7.10 | py36h9f0ad1d_0 7.6 MB conda-forge\n",
" numpy-1.19.4 | py36h2aa4a07_2 5.3 MB conda-forge\n",
" ocl-icd-2.2.14 | h7f98852_0 118 KB conda-forge\n",
" openmm-7.5.0 | py36hd44746c_4 10.9 MB conda-forge\n",
" pyrsistent-0.17.3 | py36h1d69622_1 89 KB conda-forge\n",
" setuptools-49.6.0 | py36h9880bd3_2 947 KB conda-forge\n",
" terminado-0.9.1 | py36h5fab9bb_1 25 KB conda-forge\n",
" ------------------------------------------------------------\n",
" Total: 28.2 MB\n",
"\n",
"The following NEW packages will be INSTALLED:\n",
"\n",
" cudatoolkit conda-forge/linux-64::cudatoolkit-11.0.3-h15472ef_6\n",
" fftw conda-forge/linux-64::fftw-3.3.8-nompi_h8cb7ab2_1114\n",
" libblas conda-forge/linux-64::libblas-3.9.0-3_openblas\n",
" libcblas conda-forge/linux-64::libcblas-3.9.0-3_openblas\n",
" libgfortran-ng conda-forge/linux-64::libgfortran-ng-9.3.0-he4bcb1c_17\n",
" libgfortran5 conda-forge/linux-64::libgfortran5-9.3.0-he4bcb1c_17\n",
" liblapack conda-forge/linux-64::liblapack-3.9.0-3_openblas\n",
" libopenblas conda-forge/linux-64::libopenblas-0.3.12-pthreads_h4812303_1\n",
" numpy conda-forge/linux-64::numpy-1.19.4-py36h2aa4a07_2\n",
" ocl-icd conda-forge/linux-64::ocl-icd-2.2.14-h7f98852_0\n",
" ocl-icd-system conda-forge/linux-64::ocl-icd-system-1.0.0-1\n",
" openmm conda-forge/linux-64::openmm-7.5.0-py36hd44746c_4\n",
" prompt_toolkit conda-forge/noarch::prompt_toolkit-3.0.8-hd8ed1ab_0\n",
" typing_extensions conda-forge/noarch::typing_extensions-3.7.4.3-py_0\n",
"\n",
"The following packages will be REMOVED:\n",
"\n",
" argon2-cffi-20.1.0-py38h25fe258_2\n",
"\n",
"The following packages will be UPDATED:\n",
"\n",
" entrypoints conda-forge/linux-64::entrypoints-0.3~ --> conda-forge/noarch::entrypoints-0.3-pyhd8ed1ab_1003\n",
" jsonschema conda-forge/linux-64::jsonschema-3.2.~ --> conda-forge/noarch::jsonschema-3.2.0-py_2\n",
" libstdcxx-ng pkgs/main::libstdcxx-ng-9.1.0-hdf63c6~ --> conda-forge::libstdcxx-ng-9.3.0-h2ae2ef3_17\n",
" pexpect conda-forge/linux-64::pexpect-4.8.0-p~ --> conda-forge/noarch::pexpect-4.8.0-pyh9f0ad1d_2\n",
" pickleshare conda-forge/linux-64::pickleshare-0.7~ --> conda-forge/noarch::pickleshare-0.7.5-py_1003\n",
" pip pkgs/main/linux-64::pip-20.3.1-py38h0~ --> conda-forge/noarch::pip-20.3.3-pyhd8ed1ab_0\n",
"\n",
"The following packages will be SUPERSEDED by a higher-priority channel:\n",
"\n",
" ca-certificates pkgs/main::ca-certificates-2020.12.8-~ --> conda-forge::ca-certificates-2020.12.5-ha878542_0\n",
" pandocfilters pkgs/main/linux-64::pandocfilters-1.4~ --> conda-forge/noarch::pandocfilters-1.4.2-py_1\n",
" setuptools pkgs/main::setuptools-51.0.0-py38h06a~ --> conda-forge::setuptools-49.6.0-py36h9880bd3_2\n",
" traitlets conda-forge/noarch::traitlets-5.0.5-p~ --> conda-forge/linux-64::traitlets-4.3.3-py36h9f0ad1d_1\n",
"\n",
"The following packages will be DOWNGRADED:\n",
"\n",
" brotlipy 0.7.0-py38h8df0ef7_1001 --> 0.7.0-py36he6145b8_1001\n",
" certifi 2020.12.5-py38h578d9bd_0 --> 2020.12.5-py36h5fab9bb_0\n",
" cffi 1.14.4-py38ha65f79e_1 --> 1.14.4-py36hc120d54_1\n",
" chardet 4.0.0-py38h578d9bd_0 --> 4.0.0-py36h5fab9bb_0\n",
" cryptography 3.3.1-py38h2b97feb_0 --> 3.3.1-py36h0a59100_0\n",
" importlib-metadata 3.3.0-py38h578d9bd_2 --> 3.3.0-py36h5fab9bb_2\n",
" ipykernel 5.4.2-py38h81c977d_0 --> 5.4.2-py36he448a4c_0\n",
" ipython 7.19.0-py38h81c977d_0 --> 7.12.0-py36h5ca1d4c_0\n",
" jedi 0.17.2-py38h578d9bd_1 --> 0.17.2-py36h5fab9bb_1\n",
" jupyter_core 4.7.0-py38h578d9bd_0 --> 4.7.0-py36h5fab9bb_0\n",
" markupsafe 1.1.1-py38h8df0ef7_2 --> 1.1.1-py36he6145b8_2\n",
" mistune 0.8.4-py38h25fe258_1002 --> 0.8.4-py36h1d69622_1002\n",
" nbconvert 6.0.7-py38h578d9bd_3 --> 5.6.1-py36h9f0ad1d_1\n",
" notebook 6.1.5-py38h578d9bd_0 --> 5.7.10-py36h9f0ad1d_0\n",
" pyrsistent 0.17.3-py38h25fe258_1 --> 0.17.3-py36h1d69622_1\n",
" pysocks 1.7.1-py38h924ce5b_2 --> 1.7.1-py36h9880bd3_2\n",
" python 3.8.5-h7579374_1 --> 3.6.12-hcff3b4d_2\n",
" python_abi 3.8-1_cp38 --> 3.6-1_cp36m\n",
" pyzmq 20.0.0-py38h1d1b12f_1 --> 20.0.0-py36h2b1bd32_1\n",
" terminado 0.9.1-py38h32f6830_1 --> 0.9.1-py36h5fab9bb_1\n",
" tornado 6.1-py38h25fe258_0 --> 6.1-py36h1d69622_0\n",
"\n",
"\n",
"Preparing transaction: ...working... done\n",
"Verifying transaction: ...working... done\n",
"Executing transaction: ...working... By downloading and using the CUDA Toolkit conda packages, you accept the terms and conditions of the CUDA End User License Agreement (EULA): https://docs.nvidia.com/cuda/eula/index.html\n",
"\n",
"done\n",
"\n",
"real\t0m31.991s\n",
"user\t0m26.057s\n",
"sys\t0m2.397s\n"
]
}
],
"source": [
"!time conda install -y -q -c conda-forge openmm python=3.6"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "Qal84ahazWZt"
},
"source": [
"# The trick\n",
"Since Miniconda now lives in `/usr/local` (which incidentally is also a default location to load static libraries), we only need to add the corresponding Python path to `sys.path` to enable imports."
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "S-x_hxCTvfLR"
},
"outputs": [],
"source": [
"import sys\n",
"sys.path.insert(0, '/usr/local/lib/python3.6/site-packages/')"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "PJfhPWp8AacY"
},
"source": [
"# Let's play!\n",
"Now you can just interact with the Notebook as you would normally do locally."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 287
},
"colab_type": "code",
"id": "MLW86ukM-FQo",
"outputId": "04777a02-f738-428e-d188-6659f1e0d9bb"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"There are 4 Platforms available:\n",
"\n",
"1 Reference - Successfully computed forces\n",
"2 CPU - Successfully computed forces\n",
"3 CUDA - Successfully computed forces\n",
"4 OpenCL - Successfully computed forces\n",
"\n",
"Median difference in forces between platforms:\n",
"\n",
"Reference vs. CPU: 6.3031e-06\n",
"Reference vs. CUDA: 6.73543e-06\n",
"CPU vs. CUDA: 7.81258e-07\n",
"Reference vs. OpenCL: 6.75426e-06\n",
"CPU vs. OpenCL: 8.15821e-07\n",
"CUDA vs. OpenCL: 2.17776e-07\n"
]
}
],
"source": [
"import simtk.testInstallation\n",
"simtk.testInstallation.main()"
]
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"collapsed_sections": [],
"name": "CondaExampleWithOpenMMTools.ipynb",
"provenance": [],
"toc_visible": true,
"version": "0.3.2"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
@Taoaoxiang
Copy link

Taoaoxiang commented Jul 24, 2019

Hello Jaime, this is Oliver. I tried to install openmm couple times and it didn't work. So I googled "openmm" and "colab" and found your tutorial. Then I followed every step of your tutorial, but I got totally different result. It still doesn't work for me.
So in this step
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages/')
It seems like they moved "site-packages" under python3.7. Even after appending the site-packages under python3.7, I still get the same issue.
"Error message: No module named '_openmm'"
I wonder if I didn't do it correctly or openmm has changed some setting.
Thank you!

@jaimergp
Copy link
Author

Hi Oliver, if they have migrated to Python 3.7, then you should also download the latest Miniconda (instead of v4.5.4). I will test this later this week and update this notebook. Thanks for the report!

@Taoaoxiang
Copy link

Hi Oliver, if they have migrated to Python 3.7, then you should also download the latest Miniconda (instead of v4.5.4). I will test this later this week and update this notebook. Thanks for the report!

Hello Jaime,
Thank you for your reply!
I have tried again using Anaconda2, and it works!

!wget -c https://repo.anaconda.com/archive/Anaconda2-2019.03-Linux-x86_64.sh
!bash ./Anaconda2-2019.03-Linux-x86_64.sh -b -f -p /usr/local
!conda install -y --prefix /usr/local -c omnia/label/cuda100 -c conda-forge openmm
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages/')
import simtk.testInstallation
simtk.testInstallation.main()

Still, it would be really helpful if you could get it work on Python3 (as OpenMM recommended on their website). I haven't seen any error or issue using Python2 yet.

@Taoaoxiang
Copy link

Sorry I forgot to mention that we have to change the runtime type to Python2 and of course with GPU before get started.

@jaimergp
Copy link
Author

Hi Oliver, a year later, I found out what was happening: the conda solver sneakily updates python, which creates all sorts of problems. Make sure to add python=3.6 to the list of packages passed to conda install and it should work ok!

@drcube98-mrss
Copy link

Hi, my name is Ted. I tried running your code and encountered the following error. Would be grateful if any of you could help me figure it out. I got the error while running simtk.testInstallation.main().

Failed to import OpenMM packages; OpenMM will not work.
Make sure OpenMM is installed and the library path is set correctly.

Error message: cannot import name '_openmm' from 'simtk.openmm' (/usr/local/lib/python3.6/site-packages/simtk/openmm/init.py)
An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

@jaimergp
Copy link
Author

Hi @drcube98-mrss! Colab has changed a bit its internals but I didn't update this notebook. Take a look at my condacolab project for a new updated workflow. You can see an example here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment