Recommended way to use both PyTorch and Caffe2 in a project

I’m trying to use both PyTorch and Caffe2 in a single project. To do so, I tried installing PyTorch from source (with the environment variable FULL_CAFFE2=1). This appeared to work fine. I then added pytorch/build to my PYTHONPATH.

The issue is that within a python session, I get a segmentation fault:

Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 17:14:51) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from caffe2.python import workspace
WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: No module named 'caffe2.python.caffe2_pybind11_state_hip'
Segmentation fault

Whereas if I import torch or import caffe2 first, I don’t see this error.

Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 17:14:51) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> from caffe2.python import workspace
>>> 

Maybe I didn’t install caffe2 correctly with PyTorch? I’m on Ubuntu 16.04, CUDA 8, cuDNN v6.0.21.

Installing Caffe2 first from source following this and then simply installing pytorch using pip install torch seems to work but given that caffe2 lives within pytorch, installing Caffe2 from source as described above seems redundant. Guess I’ll wait for PyTorch 1.0.