Repository: pytorch
Issue: ERROR: Command "python setup.py egg_info" when dockerfile build
Labels: needs reproduction,module: build,triaged

## 🐛 Bug


## To Reproduce

Steps to reproduce the behavior:

`docker build -t pytorch -f Dockerfile .`
```shell
    ['cmake',
     '-GNinja',
     '-DBUILDING_WITH_TORCH_LIBS=ON',
     '-DBUILD_BINARY=False',
     '-DBUILD_CAFFE2_OPS=True',
     '-DBUILD_PYTHON=True',
     '-DBUILD_SHARED_LIBS=ON',
     '-DBUILD_TEST=True',
     '-DBUILD_TORCH=ON',
     '-DCAFFE2_STATIC_LINK_CUDA=False',
     '-DCMAKE_BUILD_TYPE=Release',
     '-DCMAKE_CXX_FLAGS= ',
     '-DCMAKE_C_FLAGS= ',
     '-DCMAKE_EXE_LINKER_FLAGS=',
     '-DCMAKE_INSTALL_PREFIX=/tmp/pip-req-build-keauxx9z/torch',
     '-DCMAKE_PREFIX_PATH=/opt/conda/bin/../',
     '-DCMAKE_SHARED_LINKER_FLAGS=',
     '-DINSTALL_TEST=True',
     '-DNCCL_EXTERNAL=True',
     '-DNCCL_INCLUDE_DIR=/usr/include',
     '-DNCCL_ROOT_DIR=/usr/',
     '-DNCCL_SYSTEM_LIB=/usr/lib/x86_64-linux-gnu/libnccl.so.2.4.2',
     '-DNUMPY_INCLUDE_DIR=/opt/conda/lib/python3.6/site-packages/numpy/core/include',
     '-DONNX_ML=False',
     '-DONNX_NAMESPACE=onnx_torch',
     '-DPYTHON_EXECUTABLE=/opt/conda/bin/python',
     '-DPYTHON_INCLUDE_DIR=/opt/conda/include/python3.6m',
     '-DPYTHON_LIBRARY=/opt/conda/lib/libpython3.6m.so.1.0',
     '-DTHD_SO_VERSION=1',
     '-DTORCH_BUILD_VERSION=1.1.0a0+fc00bfd',
     '-DUSE_CUDA=True',
     '-DUSE_DISTRIBUTED=True',
     '-DUSE_FBGEMM=True',
     '-DUSE_FFMPEG=False',
     '-DUSE_LEVELDB=False',
     '-DUSE_LMDB=False',
     '-DUSE_MKLDNN=True',
     '-DUSE_NCCL=True',
     '-DUSE_NNPACK=True',
     '-DUSE_NUMPY=True',
     '-DUSE_OPENCV=False',
     '-DUSE_QNNPACK=True',
     '-DUSE_ROCM=False',
     '-DUSE_SYSTEM_EIGEN_INSTALL=OFF',
     '-DUSE_SYSTEM_NCCL=True',
     '-DUSE_TENSORRT=False',
     '-DMKLDNN_ENABLE_CONCURRENT_EXEC=ON',
     '/tmp/pip-req-build-keauxx9z']
Cleaning up...
  Removing source in /tmp/pip-req-build-keauxx9z
Removed file:///opt/pytorch from build tracker '/tmp/pip-req-tracker-27yyn7rz'
Removed build tracker '/tmp/pip-req-tracker-27yyn7rz'
ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-keauxx9z/
Exception information:
Traceback (most recent call last):
  File "/opt/conda/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 178, in main
    status = self.run(options, args)
  File "/opt/conda/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 352, in run
    resolver.resolve(requirement_set)
  File "/opt/conda/lib/python3.6/site-packages/pip/_internal/resolve.py", line 131, in resolve
    self._resolve_one(requirement_set, req)
  File "/opt/conda/lib/python3.6/site-packages/pip/_internal/resolve.py", line 294, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/opt/conda/lib/python3.6/site-packages/pip/_internal/resolve.py", line 242, in _get_abstract_dist_for
    self.require_hashes
  File "/opt/conda/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 368, in prepare_linked_requirement
    abstract_dist.prep_for_dist(finder, self.build_isolation)
  File "/opt/conda/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 177, in prep_for_dist
    self.req.prepare_metadata()
  File "/opt/conda/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 539, in prepare_metadata
    self.run_egg_info()
  File "/opt/conda/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 617, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/opt/conda/lib/python3.6/site-packages/pip/_internal/utils/misc.py", line 776, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip._internal.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-keauxx9z/
The command '/bin/sh -c TORCH_CUDA_ARCH_LIST="3.5 5.2 6.0 6.1 7.0+PTX" TORCH_NVCC_FLAGS="-Xfatbin -compress-all"     CMAKE_PREFIX_PATH="$(dirname $(which conda))/../"     pip install -v .' returned a non-zero code: 1
```

## Expected behavior

This will be issue, How i can fix it?
```dockerfile
RUN TORCH_CUDA_ARCH_LIST="3.5 5.2 6.0 6.1 7.0+PTX" TORCH_NVCC_FLAGS="-Xfatbin -compress-all" \
    CMAKE_PREFIX_PATH="$(dirname $(which conda))/../" \
    pip install -v .
```

## Environment


 - PyTorch Version (e.g., 1.0): lastest
 - OS (e.g., Linux): Window10 Home
 - How you installed PyTorch (`conda`, `pip`, source): source
 - Build command you used (if compiling from source): `docker build -t pytorch -f Dockerfile .`
 - Python version: master
 - CUDA/cuDNN version: None
 - GPU models and configuration: None
 - Any other relevant information:

## Additional context

My dockerfile has been modified very little.
```dockerfile
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu16.04
ARG PYTHON_VERSION=3.6
RUN apt-get update && apt-get install -y --no-install-recommends \
         build-essential \
         cmake \
         git \
         curl \
         vim \
         ca-certificates \
         libjpeg-dev \
         libpng-dev &&\
     rm -rf /var/lib/apt/lists/*


RUN curl -o ~/miniconda.sh -O  https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh  && \
     chmod +x ~/miniconda.sh && \
     ~/miniconda.sh -b -p /opt/conda && \
     rm ~/miniconda.sh && \
     /opt/conda/bin/conda install -y python=$PYTHON_VERSION numpy pyyaml scipy ipython mkl mkl-include cython typing && \
     /opt/conda/bin/conda install -y -c pytorch magma-cuda100 && \
     /opt/conda/bin/conda clean -ya
ENV PATH /opt/conda/bin:$PATH
RUN pip install ninja
WORKDIR /opt
RUN git clone https://github.com/pytorch/pytorch

# This must be done before pip so that requirements.txt is available
WORKDIR /opt/pytorch
COPY . .

RUN git submodule update --init
RUN TORCH_CUDA_ARCH_LIST="3.5 5.2 6.0 6.1 7.0+PTX" TORCH_NVCC_FLAGS="-Xfatbin -compress-all" \
    CMAKE_PREFIX_PATH="$(dirname $(which conda))/../" \
    pip install -v .

RUN git clone https://github.com/pytorch/vision.git && cd vision && pip install -v .

WORKDIR /workspace
RUN chmod -R a+w /workspace
```