We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
WandbLogger cannot be used with 'ddp'
<!-- 
### Common bugs:
1. Tensorboard not showing in Jupyter-notebook see [issue 79](https://github.com/PyTorchLightning/pytorch-lightning/issues/79).    
2. PyTorch 1.1.0 vs 1.2.0 support [see FAQ](https://github.com/PyTorchLightning/pytorch-lightning#faq)    
-->

## 🐛 Bug

wandb modifies `init` such that a child process calling init returns None if the master process has called init. This seems to cause a bug with ddp, and results in rank zero having experiment = None, which crashes the program.

### To Reproduce

Can be reproduced with the basic MNIST gpu template, simply add a WandbLogger and pass 'ddp' as the distributed backend.
```
-- Process 0 terminated with the following error:
Traceback (most recent call last):
  File "/home/rmrao/anaconda3/lib/python3.6/site-packages/torch/multiprocessing/spawn.py", line 19, in _wrap
    fn(i, *args)
  File "/home/rmrao/anaconda3/lib/python3.6/site-packages/pytorch_lightning/trainer/distrib_data_parallel.py", line 331, in ddp_train
    self.run_pretrain_routine(model)
  File "/home/rmrao/anaconda3/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 757, in run_pretrain_routine
    self.logger.log_hyperparams(ref_model.hparams)
  File "/home/rmrao/anaconda3/lib/python3.6/site-packages/pytorch_lightning/logging/base.py", line 14, in wrapped_fn
    fn(self, *args, **kwargs)
  File "/home/rmrao/anaconda3/lib/python3.6/site-packages/pytorch_lightning/logging/wandb.py", line 79, in log_hyperparams
    self.experiment.config.update(params)
AttributeError: 'NoneType' object has no attribute 'config'
```

This occurs with the latest wandb version and with pytorch-lightning 0.6.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pytorch_lightning/loggers/wandb.py`
Content:
```
1 r"""
2 
3 .. _wandb:
4 
5 WandbLogger
6 -------------
7 """
8 import os
9 from argparse import Namespace
10 from typing import Optional, List, Dict, Union, Any
11 
12 import torch.nn as nn
13 
14 try:
15     import wandb
16     from wandb.wandb_run import Run
17 except ImportError:  # pragma: no-cover
18     raise ImportError('You want to use `wandb` logger which is not installed yet,'  # pragma: no-cover
19                       ' install it with `pip install wandb`.')
20 
21 from pytorch_lightning.loggers.base import LightningLoggerBase, rank_zero_only
22 
23 
24 class WandbLogger(LightningLoggerBase):
25     """
26     Logger for `W&B <https://www.wandb.com/>`_.
27 
28     Args:
29         name (str): display name for the run.
30         save_dir (str): path where data is saved.
31         offline (bool): run offline (data can be streamed later to wandb servers).
32         id or version (str): sets the version, mainly used to resume a previous run.
33         anonymous (bool): enables or explicitly disables anonymous logging.
34         project (str): the name of the project to which this run will belong.
35         tags (list of str): tags associated with this run.
36         log_model (bool): save checkpoints in wandb dir to upload on W&B servers.
37 
38     Example
39     --------
40     .. code-block:: python
41 
42         from pytorch_lightning.loggers import WandbLogger
43         from pytorch_lightning import Trainer
44 
45         wandb_logger = WandbLogger()
46         trainer = Trainer(logger=wandb_logger)
47     """
48 
49     def __init__(self, name: Optional[str] = None, save_dir: Optional[str] = None,
50                  offline: bool = False, id: Optional[str] = None, anonymous: bool = False,
51                  version: Optional[str] = None, project: Optional[str] = None,
52                  tags: Optional[List[str]] = None, log_model: bool = False,
53                  experiment=None, entity=None):
54         super().__init__()
55         self._name = name
56         self._save_dir = save_dir
57         self._anonymous = 'allow' if anonymous else None
58         self._id = version or id
59         self._tags = tags
60         self._project = project
61         self._experiment = experiment
62         self._offline = offline
63         self._entity = entity
64         self._log_model = log_model
65 
66     def __getstate__(self):
67         state = self.__dict__.copy()
68         # cannot be pickled
69         state['_experiment'] = None
70         # args needed to reload correct experiment
71         state['_id'] = self.experiment.id
72         return state
73 
74     @property
75     def experiment(self) -> Run:
76         r"""
77 
78           Actual wandb object. To use wandb features do the following.
79 
80           Example::
81 
82               self.logger.experiment.some_wandb_function()
83 
84           """
85         if self._experiment is None:
86             if self._offline:
87                 os.environ['WANDB_MODE'] = 'dryrun'
88             self._experiment = wandb.init(
89                 name=self._name, dir=self._save_dir, project=self._project, anonymous=self._anonymous,
90                 id=self._id, resume='allow', tags=self._tags, entity=self._entity)
91             # save checkpoints in wandb dir to upload on W&B servers
92             if self._log_model:
93                 self.save_dir = self._experiment.dir
94         return self._experiment
95 
96     def watch(self, model: nn.Module, log: str = 'gradients', log_freq: int = 100):
97         wandb.watch(model, log=log, log_freq=log_freq)
98 
99     @rank_zero_only
100     def log_hyperparams(self, params: Union[Dict[str, Any], Namespace]) -> None:
101         params = self._convert_params(params)
102         self.experiment.config.update(params)
103 
104     @rank_zero_only
105     def log_metrics(self, metrics: Dict[str, float], step: Optional[int] = None) -> None:
106         if step is not None:
107             metrics['global_step'] = step
108         self.experiment.log(metrics)
109 
110     @property
111     def name(self) -> str:
112         return self.experiment.project_name()
113 
114     @property
115     def version(self) -> str:
116         return self.experiment.id
117
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pytorch_lightning/loggers/wandb.py b/pytorch_lightning/loggers/wandb.py
--- a/pytorch_lightning/loggers/wandb.py
+++ b/pytorch_lightning/loggers/wandb.py
@@ -65,10 +65,11 @@
 
     def __getstate__(self):
         state = self.__dict__.copy()
+        # args needed to reload correct experiment
+        state['_id'] = self._experiment.id if self._experiment is not None else None
+
         # cannot be pickled
         state['_experiment'] = None
-        # args needed to reload correct experiment
-        state['_id'] = self.experiment.id
         return state
 
     @property
@@ -87,7 +88,7 @@
                 os.environ['WANDB_MODE'] = 'dryrun'
             self._experiment = wandb.init(
                 name=self._name, dir=self._save_dir, project=self._project, anonymous=self._anonymous,
-                id=self._id, resume='allow', tags=self._tags, entity=self._entity)
+                reinit=True, id=self._id, resume='allow', tags=self._tags, entity=self._entity)
             # save checkpoints in wandb dir to upload on W&B servers
             if self._log_model:
                 self.save_dir = self._experiment.dir
@@ -109,8 +110,11 @@
 
     @property
     def name(self) -> str:
-        return self.experiment.project_name()
+        # don't create an experiment if we don't have one
+        name = self._experiment.project_name() if self._experiment else None
+        return name
 
     @property
     def version(self) -> str:
-        return self.experiment.id
+        # don't create an experiment if we don't have one
+        return self._experiment.id if self._experiment else None

{"golden_diff": "diff --git a/pytorch_lightning/loggers/wandb.py b/pytorch_lightning/loggers/wandb.py\n--- a/pytorch_lightning/loggers/wandb.py\n+++ b/pytorch_lightning/loggers/wandb.py\n@@ -65,10 +65,11 @@\n \n     def __getstate__(self):\n         state = self.__dict__.copy()\n+        # args needed to reload correct experiment\n+        state['_id'] = self._experiment.id if self._experiment is not None else None\n+\n         # cannot be pickled\n         state['_experiment'] = None\n-        # args needed to reload correct experiment\n-        state['_id'] = self.experiment.id\n         return state\n \n     @property\n@@ -87,7 +88,7 @@\n                 os.environ['WANDB_MODE'] = 'dryrun'\n             self._experiment = wandb.init(\n                 name=self._name, dir=self._save_dir, project=self._project, anonymous=self._anonymous,\n-                id=self._id, resume='allow', tags=self._tags, entity=self._entity)\n+                reinit=True, id=self._id, resume='allow', tags=self._tags, entity=self._entity)\n             # save checkpoints in wandb dir to upload on W&B servers\n             if self._log_model:\n                 self.save_dir = self._experiment.dir\n@@ -109,8 +110,11 @@\n \n     @property\n     def name(self) -> str:\n-        return self.experiment.project_name()\n+        # don't create an experiment if we don't have one\n+        name = self._experiment.project_name() if self._experiment else None\n+        return name\n \n     @property\n     def version(self) -> str:\n-        return self.experiment.id\n+        # don't create an experiment if we don't have one\n+        return self._experiment.id if self._experiment else None\n", "issue": "WandbLogger cannot be used with 'ddp'\n<!-- \r\n### Common bugs:\r\n1. Tensorboard not showing in Jupyter-notebook see [issue 79](https://github.com/PyTorchLightning/pytorch-lightning/issues/79).    \r\n2. PyTorch 1.1.0 vs 1.2.0 support [see FAQ](https://github.com/PyTorchLightning/pytorch-lightning#faq)    \r\n-->\r\n\r\n## \ud83d\udc1b Bug\r\n\r\nwandb modifies `init` such that a child process calling init returns None if the master process has called init. This seems to cause a bug with ddp, and results in rank zero having experiment = None, which crashes the program.\r\n\r\n### To Reproduce\r\n\r\nCan be reproduced with the basic MNIST gpu template, simply add a WandbLogger and pass 'ddp' as the distributed backend.\r\n```\r\n-- Process 0 terminated with the following error:\r\nTraceback (most recent call last):\r\n  File \"/home/rmrao/anaconda3/lib/python3.6/site-packages/torch/multiprocessing/spawn.py\", line 19, in _wrap\r\n    fn(i, *args)\r\n  File \"/home/rmrao/anaconda3/lib/python3.6/site-packages/pytorch_lightning/trainer/distrib_data_parallel.py\", line 331, in ddp_train\r\n    self.run_pretrain_routine(model)\r\n  File \"/home/rmrao/anaconda3/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py\", line 757, in run_pretrain_routine\r\n    self.logger.log_hyperparams(ref_model.hparams)\r\n  File \"/home/rmrao/anaconda3/lib/python3.6/site-packages/pytorch_lightning/logging/base.py\", line 14, in wrapped_fn\r\n    fn(self, *args, **kwargs)\r\n  File \"/home/rmrao/anaconda3/lib/python3.6/site-packages/pytorch_lightning/logging/wandb.py\", line 79, in log_hyperparams\r\n    self.experiment.config.update(params)\r\nAttributeError: 'NoneType' object has no attribute 'config'\r\n```\r\n\r\nThis occurs with the latest wandb version and with pytorch-lightning 0.6.\r\n\n", "before_files": [{"content": "r\"\"\"\n\n.. _wandb:\n\nWandbLogger\n-------------\n\"\"\"\nimport os\nfrom argparse import Namespace\nfrom typing import Optional, List, Dict, Union, Any\n\nimport torch.nn as nn\n\ntry:\n    import wandb\n    from wandb.wandb_run import Run\nexcept ImportError:  # pragma: no-cover\n    raise ImportError('You want to use `wandb` logger which is not installed yet,'  # pragma: no-cover\n                      ' install it with `pip install wandb`.')\n\nfrom pytorch_lightning.loggers.base import LightningLoggerBase, rank_zero_only\n\n\nclass WandbLogger(LightningLoggerBase):\n    \"\"\"\n    Logger for `W&B <https://www.wandb.com/>`_.\n\n    Args:\n        name (str): display name for the run.\n        save_dir (str): path where data is saved.\n        offline (bool): run offline (data can be streamed later to wandb servers).\n        id or version (str): sets the version, mainly used to resume a previous run.\n        anonymous (bool): enables or explicitly disables anonymous logging.\n        project (str): the name of the project to which this run will belong.\n        tags (list of str): tags associated with this run.\n        log_model (bool): save checkpoints in wandb dir to upload on W&B servers.\n\n    Example\n    --------\n    .. code-block:: python\n\n        from pytorch_lightning.loggers import WandbLogger\n        from pytorch_lightning import Trainer\n\n        wandb_logger = WandbLogger()\n        trainer = Trainer(logger=wandb_logger)\n    \"\"\"\n\n    def __init__(self, name: Optional[str] = None, save_dir: Optional[str] = None,\n                 offline: bool = False, id: Optional[str] = None, anonymous: bool = False,\n                 version: Optional[str] = None, project: Optional[str] = None,\n                 tags: Optional[List[str]] = None, log_model: bool = False,\n                 experiment=None, entity=None):\n        super().__init__()\n        self._name = name\n        self._save_dir = save_dir\n        self._anonymous = 'allow' if anonymous else None\n        self._id = version or id\n        self._tags = tags\n        self._project = project\n        self._experiment = experiment\n        self._offline = offline\n        self._entity = entity\n        self._log_model = log_model\n\n    def __getstate__(self):\n        state = self.__dict__.copy()\n        # cannot be pickled\n        state['_experiment'] = None\n        # args needed to reload correct experiment\n        state['_id'] = self.experiment.id\n        return state\n\n    @property\n    def experiment(self) -> Run:\n        r\"\"\"\n\n          Actual wandb object. To use wandb features do the following.\n\n          Example::\n\n              self.logger.experiment.some_wandb_function()\n\n          \"\"\"\n        if self._experiment is None:\n            if self._offline:\n                os.environ['WANDB_MODE'] = 'dryrun'\n            self._experiment = wandb.init(\n                name=self._name, dir=self._save_dir, project=self._project, anonymous=self._anonymous,\n                id=self._id, resume='allow', tags=self._tags, entity=self._entity)\n            # save checkpoints in wandb dir to upload on W&B servers\n            if self._log_model:\n                self.save_dir = self._experiment.dir\n        return self._experiment\n\n    def watch(self, model: nn.Module, log: str = 'gradients', log_freq: int = 100):\n        wandb.watch(model, log=log, log_freq=log_freq)\n\n    @rank_zero_only\n    def log_hyperparams(self, params: Union[Dict[str, Any], Namespace]) -> None:\n        params = self._convert_params(params)\n        self.experiment.config.update(params)\n\n    @rank_zero_only\n    def log_metrics(self, metrics: Dict[str, float], step: Optional[int] = None) -> None:\n        if step is not None:\n            metrics['global_step'] = step\n        self.experiment.log(metrics)\n\n    @property\n    def name(self) -> str:\n        return self.experiment.project_name()\n\n    @property\n    def version(self) -> str:\n        return self.experiment.id\n", "path": "pytorch_lightning/loggers/wandb.py"}], "after_files": [{"content": "r\"\"\"\n\n.. _wandb:\n\nWandbLogger\n-------------\n\"\"\"\nimport os\nfrom argparse import Namespace\nfrom typing import Optional, List, Dict, Union, Any\n\nimport torch.nn as nn\n\ntry:\n    import wandb\n    from wandb.wandb_run import Run\nexcept ImportError:  # pragma: no-cover\n    raise ImportError('You want to use `wandb` logger which is not installed yet,'  # pragma: no-cover\n                      ' install it with `pip install wandb`.')\n\nfrom pytorch_lightning.loggers.base import LightningLoggerBase, rank_zero_only\n\n\nclass WandbLogger(LightningLoggerBase):\n    \"\"\"\n    Logger for `W&B <https://www.wandb.com/>`_.\n\n    Args:\n        name (str): display name for the run.\n        save_dir (str): path where data is saved.\n        offline (bool): run offline (data can be streamed later to wandb servers).\n        id or version (str): sets the version, mainly used to resume a previous run.\n        anonymous (bool): enables or explicitly disables anonymous logging.\n        project (str): the name of the project to which this run will belong.\n        tags (list of str): tags associated with this run.\n        log_model (bool): save checkpoints in wandb dir to upload on W&B servers.\n\n    Example\n    --------\n    .. code-block:: python\n\n        from pytorch_lightning.loggers import WandbLogger\n        from pytorch_lightning import Trainer\n\n        wandb_logger = WandbLogger()\n        trainer = Trainer(logger=wandb_logger)\n    \"\"\"\n\n    def __init__(self, name: Optional[str] = None, save_dir: Optional[str] = None,\n                 offline: bool = False, id: Optional[str] = None, anonymous: bool = False,\n                 version: Optional[str] = None, project: Optional[str] = None,\n                 tags: Optional[List[str]] = None, log_model: bool = False,\n                 experiment=None, entity=None):\n        super().__init__()\n        self._name = name\n        self._save_dir = save_dir\n        self._anonymous = 'allow' if anonymous else None\n        self._id = version or id\n        self._tags = tags\n        self._project = project\n        self._experiment = experiment\n        self._offline = offline\n        self._entity = entity\n        self._log_model = log_model\n\n    def __getstate__(self):\n        state = self.__dict__.copy()\n        # args needed to reload correct experiment\n        state['_id'] = self._experiment.id if self._experiment is not None else None\n\n        # cannot be pickled\n        state['_experiment'] = None\n        return state\n\n    @property\n    def experiment(self) -> Run:\n        r\"\"\"\n\n          Actual wandb object. To use wandb features do the following.\n\n          Example::\n\n              self.logger.experiment.some_wandb_function()\n\n          \"\"\"\n        if self._experiment is None:\n            if self._offline:\n                os.environ['WANDB_MODE'] = 'dryrun'\n            self._experiment = wandb.init(\n                name=self._name, dir=self._save_dir, project=self._project, anonymous=self._anonymous,\n                reinit=True, id=self._id, resume='allow', tags=self._tags, entity=self._entity)\n            # save checkpoints in wandb dir to upload on W&B servers\n            if self._log_model:\n                self.save_dir = self._experiment.dir\n        return self._experiment\n\n    def watch(self, model: nn.Module, log: str = 'gradients', log_freq: int = 100):\n        wandb.watch(model, log=log, log_freq=log_freq)\n\n    @rank_zero_only\n    def log_hyperparams(self, params: Union[Dict[str, Any], Namespace]) -> None:\n        params = self._convert_params(params)\n        self.experiment.config.update(params)\n\n    @rank_zero_only\n    def log_metrics(self, metrics: Dict[str, float], step: Optional[int] = None) -> None:\n        if step is not None:\n            metrics['global_step'] = step\n        self.experiment.log(metrics)\n\n    @property\n    def name(self) -> str:\n        # don't create an experiment if we don't have one\n        name = self._experiment.project_name() if self._experiment else None\n        return name\n\n    @property\n    def version(self) -> str:\n        # don't create an experiment if we don't have one\n        return self._experiment.id if self._experiment else None\n", "path": "pytorch_lightning/loggers/wandb.py"}]}