Repository: pytorch
Issue: [caffe2] Caffe2 GlobalInit should be run before any other API calls
Labels: caffe2

There is no error when the code (ipynb) below is ran:


```python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

# We'll also import a few standard python libraries
from matplotlib import pyplot
import numpy as np
import time

# These are the droids you are looking for.
from caffe2.python import core, workspace, brew
from caffe2.proto import caffe2_pb2
from caffe2.python.model_helper import ModelHelper
```


```python
inp = np.random.randn(7, 3, 224, 224).astype(np.float32)
```


```python
workspace.FeedBlob('X', inp)
```




    True




```python
model = ModelHelper()
```


```python
conv1 = brew.conv(model, 'X', 'conv1', 3, 5, 3)
```


```python
workspace.RunNetOnce(model.param_init_net)
```




    True




```python
workspace.CreateNet(model.net)
```




    True




```python
workspace.RunNet(model.net)
```




    True


However, if I run the same code in py file:



```python
from __future__ import absolute_import                                                                                  
from __future__ import division                                                                                         
from __future__ import print_function                                                                                   
from __future__ import unicode_literals                                                                                 
                                                                                                                        
# We'll also import a few standard python libraries                                                                     
from matplotlib import pyplot                                                                                           
import numpy as np                                                                                                      
import time                                                                                                             
                                                                                                                        
# These are the droids you are looking for.                                                                             
from caffe2.python import core, workspace, brew                                                                         
from caffe2.proto import caffe2_pb2                                                                                     
from caffe2.python.model_helper import ModelHelper                                                                      
                                                                                                                        
inp = np.random.randn(7, 3, 224, 224).astype(np.float32)                                                                
workspace.FeedBlob('X', inp)                                                                                            
model = ModelHelper()                                                                                                   
conv1 = brew.conv(model, 'X', 'conv1', 3, 5, 3)                                                                         
workspace.RunNetOnce(model.param_init_net)                                                                              
workspace.CreateNet(model.net)                                                                                          
workspace.RunNet(model.net)                                                                                             
print(model.net.Proto())                                                                                                
print(workspace.FetchBlob('conv1').shape, "Final")                                                                      

```



Error (while running in py file):

```bash

WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.

WARNING: Logging before InitGoogleLogging() is written to STDERR

W1126 14:07:14.579519 321242560 init.h:99] Caffe2 GlobalInit should be run before any other API calls.

W1126 14:07:14.579742 321242560 init.h:99] Caffe2 GlobalInit should be run before any other API calls.

I1126 14:07:14.579951 321242560 operator.cc:169] Engine CUDNN is not available for operator Conv.

```