Repository: pytorch
Issue: Build issue when installing pytorch with USE_FFMPEG=1 USE_OPENCV=1 
Labels: module: build,triaged

## 🐛 Bug

I'm trying to build pytorch with video operators enabled in caffe2, steps taken from [VMZ repository](https://github.com/facebookresearch/VMZ/blob/master/tutorials/Installation_guide.md#ubuntu).
Any help or insights would be appreciated. 
However, whenever I don't use the below env variables, the build works fine. 

## To Reproduce
USE_OPENCV=1 USE_FFMPEG=1 USE_LMDB=1 python setup.py install 

Steps to reproduce the behavior:

1. docker pull pytorch/pytorch:1.5-cuda10.1-cudnn7-devel
2. git clone --recursive https://github.com/pytorch/pytorch.git
3. cd pytorch; USE_OPENCV=1 USE_FFMPEG=1 USE_LMDB=1 python setup.py install 

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

```
[1728/4811] Building CXX object c10/CMakeFiles/c10.dir/util/numa.cpp.o
[1729/4811] Building CXX object c10/CMakeFiles/c10.dir/core/UndefinedTensorImpl.cpp.o
[1730/4811] Building CXX object c10/test/CMakeFiles/c10_tempfile_test.dir/util/tempfile_test.cpp.o
[1731/4811] Building CXX object c10/test/CMakeFiles/c10_flags_test.dir/util/flags_test.cpp.o
[1732/4811] Building CXX object c10/test/CMakeFiles/c10_Array_test.dir/util/Array_test.cpp.o
[1733/4811] Building C object caffe2/CMakeFiles/torch_global_deps.dir/__/torch/csrc/empty.c.o
[1734/4811] Linking C shared library lib/libtorch_global_deps.so
FAILED: lib/libtorch_global_deps.so
: && /usr/bin/cc -fPIC -fopenmp -DNDEBUG -O3 -DNDEBUG -DNDEBUG  -Wl,--no-as-needed -rdynamic -shared -Wl,-soname,libtorch_global_deps.so -o lib/libtorch_global_deps.so caffe2/CMakeFiles/torch_global_deps.dir/__/torch/csrc/empty.c.o -L/usr/local/cuda/lib64 -Wl,-rpath,/usr/local/cuda/lib64:/usr/lib/x86_64-linux-gnu/openmpi/lib:::::::: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so /usr/local/cuda/lib64/libcurand.so /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcufft.so /usr/lib/x86_64-linux-gnu/libcublas.so -lCUDA_cublas_device_LIBRARY-NOTFOUND /usr/local/cuda/lib64/libcudart.so /usr/local/cuda/lib64/libnvToolsExt.so && :
/usr/bin/ld: cannot find -lCUDA_cublas_device_LIBRARY-NOTFOUND
collect2: error: ld returned 1 exit status


```

## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

## Environment

Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

You can get the script and run it with:
```
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```

 - PyTorch Version (e.g., 1.0):N/A
 - OS (e.g., Linux): 18.04.4 LTS
 - How you installed PyTorch (`conda`, `pip`, source): source
 - Build command you used (if compiling from source): USE_OPENCV=1 USE_LMDB=1 USE_FFMPEG=1 python setup.py install
 - Python version: 3.7
 - CUDA/cuDNN version: 
     CUDA runtime version: 10.1.243
     cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5

 - GPU models and configuration: GPU 0: Tesla V100-SXM2-32GB
 - Any other relevant information:

## Additional context

cc @malfet