kengz / SLM-Lab

Modular Deep Reinforcement Learning framework in PyTorch. Companion library of the book "Foundations of Deep Reinforcement Learning".
https://slm-lab.gitbook.io/slm-lab/
MIT License
1.25k stars 264 forks source link

Running inside Google Colab #373

Closed philwinder closed 5 years ago

philwinder commented 5 years ago

I'm attempting to get SLM-Lab working inside a Google Colab instance. I can't get the getting started example working because of a torch error.

To Reproduce Run this notebook

Error logs

Traceback (most recent call last):
  File "run_lab.py", line 77, in <module>
    mp.set_start_method('spawn')  # for distributed pytorch to work
  File "/usr/lib/python3.6/multiprocessing/context.py", line 242, in set_start_method
    raise RuntimeError('context has already been set')
RuntimeError: context has already been set

I think the solution is to add some exception handling around the mp.set_start_method('spawn') call, but I'm not certain about that.

Thanks!

kengz commented 5 years ago

We've never ran it on colab notebook, thanks for trying this out! Seem like the runtime is different than when running from a plain bash shell. I'll push a patch for this

btw, a way to use the optimized conda environment inside colab is to install following the SLM Lab README and run the conda and python command in one line: !conda activate lab && python run_lab.py slm_lab/spec/demo.json dqn_cartpole dev